How to align next line with comments and not code

Answered

Hello,

 

I noticed that when I add a comment and then click "enter" (add a new line) the new line is not aligned with the comment but with the code above the comment.

 

So if I write:

def foo():

    pass

# write a function starting after this comment

 

If I click "enter" after writing the comment above the next line will have an indent, as if I wanted to continue writing the "foo" function.

Is there any way to disable this? so that the next line is not indented?

 

Thank you.

0
1 comment

Hi there! Sorry for the late update.

 

Currently indentation of comments is not taken into account when calculating indents/block structure of a program just like in Python interpreter itself. Unfortunately, it causes some unwanted side-effects in the formatter like the one you've encountered. It's been reported before, for example, in PY-17834. We're going to address this issue in one of the upcoming releases, so stay tuned.

0

Please sign in to leave a comment.