-
Notifications
You must be signed in to change notification settings - Fork 749
Description
pep8
neglects to complain about code with mismatched indentation levels, such as this snippet:
if True:
print 'yes'
else:
print 'no'
Example taken from a complaint about this problem on StackOverflow. pylint
gives a reasonable error here, namely:
W: 2, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
The PEP 8 standard says simply:
Use 4 spaces per indentation level.
And I would like to have a warning about any indentation level other than 4 spaces. Here's the beginning of a fix. I think these errors might need to be separated based on:
a. mixing different indentation levels, as in the example above
b. using any indentation level other than 4 spaces (including tabs)
IMO a.) should definitely be an error by default. I can see the case for b.) being off by default and/or just a warning, particularly since PEP 8 makes an allowance for tabs by saying:
Tabs should be used solely to remain consistent with code that is already indented with tabs.