Menu

#1360 code analysis finds indentation errors on comment lines

open
Editor (491)
5
2011-07-26
2011-07-26
J D
No

Code analysis displays "bad indentation" diagnostics on comment lines that do not start on a tab stop. (By "comment line" I mean a line where the first non-whitespace is a "#".)

This is a bug because the indentation of comments is purely cosmetic and has no semantic function. It does not matter to the Python interpreter if a comment line is not indented the same as the surrounding code. In fact, using whitespace to help format comments can make them easier to read, but doing so elicits code analysis warnings, which really are just noise, unless the comments are kept strictly in tab-stop columns. This is needlessly restrictive.

It's not really part of the bug, but let me add as a remark that the "mixed indentation" warning that is generated when the leading whitespace has a mix of tabs and spaces is probably useful and should be maintained. If the intent is to produce a formatted appearance of the comment block, then mixed indentation doesn't do what is wanted if the file is opened in an environment with a different tab stop convention.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.