long-winded () termination indentation

Bug #826144 reported by Glenn Linderman
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

# test code:
            if titles:
                items.append(
                    ht(
                        T.a('Sorted by title', href='#TOCtitle', ),
                        ' -- Numbers and titles sorted by title',
                        self.Tbr( epub ),
                        self.Tbr( epub ),
                        )
                    )

Placing the cursor on either of the last two lines, and hitting TAB causes it to outdent.

The style shown has been produced historically both in the GNU emacs 22.1.1 python-mode and versions of launchpad python-mode prior to 6.0 (IIRC).

When I first discovered how those python-modes worked, I was a bit surprised, because in other languages such as C and Perl, the style was to align the closing ) at the same indentation as the first line of the statement, rather than one indent level in, as shown above. But because of Python's implicit block endings (no endif), I came to agree with those python-modes, and now think that Python code looks cleaner if the closing ) is one indent in from the first character of the beginning line of the statement.

And then along comes python-mode 6.0, which changes it? Seems like a bug to me.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Barry,

get the results below, which seems the desired indent IIRC.
If it's wrong, please tell,

cheers,

Andreas

# test code:
            if titles:
                items.append(
                    ht(
                        T.a('Sorted by title', href='#TOCtitle', ),
                        ' -- Numbers and titles sorted by title',
                        self.Tbr( epub ),
                        self.Tbr( epub ),
                    )
                )

Revision history for this message
Gennady N. Uraltsev (gennady-uraltsev) wrote :

I checked and there is nothing said about this in PEP8 (Style Guide for Python Code) however I agree with Glenn that the parenthesis should be further in than python-mode puts them now in this case. IMHO the correct setting is the one in the $test code.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 826144] Re: long-winded () termination indentation

Am 14.08.2011 16:06, schrieb Gennady N. Uraltsev:
> *** This bug is a duplicate of bug 821820 ***
> https://bugs.launchpad.net/bugs/821820
>
> ** This bug has been marked a duplicate of bug 821820
> closing parentesis indent
>

Hi Gennady,

glad seeing you that active and contributing here.

Let's have a kind of organize though when working.

Think only the assignee of the bug resp. the driver of the project
should change the status flags.

The one should be a member of the team too.
Looks like a bug in launchpad permitting that now.

Would be glad if you join the team and take some bugs as assignee.

In the precise case IMHO marking it duplicate has been wrong, as the
first report was clearly a bug, but the later one still undecided for me.

If bugs are just similar, it doesn't mean duplicate, for example for
writing tests with a number pointing to the report,

so let's go on,

Andreas

Changed in python-mode:
milestone: none → 6.1
Revision history for this message
Barry Warsaw (barry) wrote :

I agree that current python-mode.el has a bug here. The closing parens should line up as given in the original bug description.

Changed in python-mode:
importance: Undecided → Medium
status: New → In Progress
Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.