From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#34268: 27.0.50; wrong indentation in python mode Date: Thu, 23 Sep 2021 23:08:19 +0200 Message-ID: <8735pvhuf0.fsf@gmail.com> References: <877df8qnmn.fsf_-_@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16481"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Valentin Ignatev , sds@gnu.org, 34268@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 23 23:09:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mTVxu-00043i-OS for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 23:09:10 +0200 Original-Received: from localhost ([::1]:42036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTVxt-0002PC-Ix for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 17:09:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTVxm-0002Oq-QJ for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2021 17:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTVxm-0007At-JF for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2021 17:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mTVxm-00049V-5g for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2021 17:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Sep 2021 21:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34268 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo confirmed Original-Received: via spool by 34268-submit@debbugs.gnu.org id=B34268.163243130815895 (code B ref 34268); Thu, 23 Sep 2021 21:09:02 +0000 Original-Received: (at 34268) by debbugs.gnu.org; 23 Sep 2021 21:08:28 +0000 Original-Received: from localhost ([127.0.0.1]:56006 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTVxE-00048J-9M for submit@debbugs.gnu.org; Thu, 23 Sep 2021 17:08:28 -0400 Original-Received: from mail-wr1-f45.google.com ([209.85.221.45]:41744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTVxC-000484-Pn for 34268@debbugs.gnu.org; Thu, 23 Sep 2021 17:08:27 -0400 Original-Received: by mail-wr1-f45.google.com with SMTP id w29so20908617wra.8 for <34268@debbugs.gnu.org>; Thu, 23 Sep 2021 14:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Cs+ZfR180w2XlAC/qEbulg5DHuV9fY8uZ/imAt7wccI=; b=gXrQ9JdES5ew/DfOWEYxLfZHUuSmKIQWNiNU5szguOoK/P4bJJDCmo+wzNVz4mzyzn z8vZM58cb/SekNCywLU8W7S7lhH7cPds2QD61vNPASPSVIRQSb/R6T5l0dirUNcwDpH3 92ACAR+tYUp+af1Sh9ff0vDC2bUpea/u5i/iCQuQA2y7eaIPlxrqZgLNpAMlMkp+HD/5 MKtislaxHscpGIv0VPeMO/yAdPV/j+MAJCBmQZiQAP7053mT86YTDc2U1TcX2VAGBbRX iqz51roar4RSicC0fWI3vxREiRRS0WERTQ8OoQCEeMripLyV8NysbkvLNfBittxY/Ofs 50Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=Cs+ZfR180w2XlAC/qEbulg5DHuV9fY8uZ/imAt7wccI=; b=aszD6gfblQrzydH9dmZwKljMnxq5FZrzFQr59HrcNC5n9P+nsuirvs/gW51pJCjaZn 4n07u0ZtRiC56JakVtXdbGXc1vODDTT0YiQjcSFF8z+gFhiYyg9iy659BVfQJCFc+ymc n9ALJs/Ru61GcVsEzwySobjoiFfgDgFKKcgzjfjF+1EyTvrT+S7L1NtGNEWTFQ4xzXUJ ielZHaRjmxVotgOkhoxyV0JL5sTHGO5VEMNQKb4s08hz97j43TApgSy7YKmC5VWeQkX/ Gfeis5EFN4hw8o4yXOceAeJLgTi8XHsFvNt51NvXhp8CYpRx/zWm0TzRVYdj07YkIikg 0pBQ== X-Gm-Message-State: AOAM532TmZZac5aROK7jDKpqICvJe1YwU+dY59ku5dqeWUMqvvH/pScS Yyh1Rp8Wdc5ZON551npLVC0= X-Google-Smtp-Source: ABdhPJx3Pv7P3a5THTmwdSwZtTA+jtIwVzdc7eUwjgxN0t7I4tQBc0Bbv2xzixKQuFtMbUO8NFodPw== X-Received: by 2002:a1c:192:: with SMTP id 140mr6541112wmb.186.1632431300792; Thu, 23 Sep 2021 14:08:20 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::2f72]) by smtp.gmail.com with ESMTPSA id t22sm2585000wmj.30.2021.09.23.14.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 14:08:20 -0700 (PDT) In-Reply-To: <877df8qnmn.fsf_-_@gnus.org> (Lars Ingebrigtsen's message of "Wed, 22 Sep 2021 23:57:52 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:215231 Archived-At: On Wed, 22 Sep 2021 at 23:57, Lars Ingebrigtsen wrote: > Valentin Ignatev writes: > >> Hey Sam, I've looked in the python.el code and it seems that it reuses >> python-indent-def-block-scale for calculating an indentation. >> >> The default value is 2 which is why inside-parens indent doubles. Setting its >> value to 1 fixes the issue. >> >> I also wonder why authors choose double indent for aligning function >> arguments. Is this some kind of an oldschool code style? :) > > (I'm going through old bug reports that unfortunately weren't resolved > at the time.) > > If I understand correctly (and I may well not -- I don't write much > python), this is just a preference issue, and setting > `python-indent-def-block-scale' to 1 fixes the issue? > > If that's what's recommended by the standards, should we flip the > default to 1? > > I've added Augusto to the CCs; perhaps he has an opinion here. I have no idea about what strong opinions other people may have here, but after looking a bit into this I think 1 is probably a better default for `python-indent-def-block-scale'. Here's what I found out: The current default of 2 for `python-indent-def-block-scale' is meant to produce this indentation style ``` def long_function_name( var_one, var_two, var_three, var_four): print(var_one) ``` which is exactly as one can find in PEP-8. Setting it to 1 produces ``` def long_function_name( var_one, var_two, var_three, var_four): print(var_one) ``` which is deemed wrong in that document. However, the above formatting looks quite unfamiliar to me anyway. I usually see one of the following styles: ``` # By far the most common style in the Python source, and, I, think, the # default style of YAPF def long_function_name(var_one, var_two, var_three, var_four): print(var_one) ``` which is insensitive to `python-indent-def-block-scale', or else ``` # Black does that, like it or not def long_function_name( var_one, var_two, var_three, var_four ): print(var_one) ``` in which case a value of 1 for `python-indent-def-block-scale' is the right thing. Finally, the situation mentioned originally in this bug report seems to be a glitch: an indentation rule that makes sense in a "for" statement is being applied where a "for" appears in a list comprehension. It's a rather minor detail, I'd say.