For readability reasons, I prefer to align some types of statements, such as in the following case (this involves some PyParsing code, but that detail doesn't matter):
_otherwise_stmt = _OTHERWISE ('otherwise statement')
_else_stmt = _ELSE ('else statement')
_end_stmt = _END ('end statement')
For this, pep8 complains about E221 ("multiple spaces before operator") and E211 ("whitespace before '('"). If I put # noqa at the end of every one of the lines, pep8 still complains about these lines. However, for other constructs elsewhere in my file, the # noqa works as expected. I'm confused about why # noqa does not make pep8 work as expected for these particular constructs.
Is this a bug in the pep8 program, or am I doing something else wrong here?
The pep8 script only lets you disable specific error codes with a # noqa comment.
See the Error Codes table; only error codes marked with (^) can be silenced this way. E211 and E221 are not among them (none of the E2* codes are):
(^)These checks can be disabled at the line level using the# noqaspecial comment. This possibility should be reserved for special cases.
Personally, I prefer using the flake8 tool, which combines pep8 with PyFlakes, and lets you use the # noqa marker far more liberally.
This is a known issue ("# noqa not honored for most Errors"), depending on who you ask.
The tool does allow you to use # noqa for some warnings but not for E221 and E211.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With