Closed PeterJCLaw closed 8 months ago
until adding a statement between the comments and your block the block has not been "ended". inside a block indentation is allowed up to the block's indentation
once you add the statement it is ended before that making it over-indented
an example in line with yours, but perhaps illustrates the point more directly
if True:
return 1
# all done!
If that's the case, could you explain why the dedented comment in the original is allowed to be followed by an indented comment?
Perhaps more consistent spellings of the rule would be:
I did already:
inside a block indentation is allowed up to the block's indentation
only a statement can end a block in python
The following is clean:
However if we add a statement after the conditional we get an error on that statement:
I'm not sure which of these is the desired behaviour for the indented comment, however it's somewhat surprising when adding a call before such a comment block that a lint error appears on a comment line which the author hasn't touched.
Both of these spellings seem to be valid Python.
For context, in the original code the commented block was itself a conditional which had been commented out, akin to:
(yes, I realise that commented-out code is itself undesirable, but it happens)