I think the behavior is correct/expected. Well, it is almost for sure if the comment was already indented, and if it wasn't it highly depends on style and what the comment was actually commenting on.

Imagine the following code:

# this function does nothing
def foo():
    pass

Now imagine I want to wrap it in a block (as in Python nested functions are valid):

def get_foo():
    # this function does nothing
    def foo():
        pass
    return foo

Here indenting the comment (which was at column 0) is the expected behavior.

So IMO this depends when too much on style and meaning to get a logic that will always Do the Right Thing™.

Though, as in your case indeed you don't want it, maybe it could be added, especially if a plugin could do this.


Reply to this email directly or view it on GitHub.