-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# noqa not honored for most Errors #180
Comments
I confirm that The best way to disable a checker is through a I guess that your use case is about SQLAlchemy, no? |
Yes, in my case it is about SQLAlchemy == comparison magic and I'd
|
Personally, I'm entirely for giving users all the freedom they might like to do whatever they please to their code. I agree it doesn't add anything useful, but it is their code and their choice. |
@sigmavirus24 Isn't PEP8 all about NOT giving the developer the choice to do whatever they please to their code? The purpose of conventions or standards is to help different people/organizations understand each others work, without having to wonder what might the author mean with this or that. |
@glarrain PEP8 is about giving the developer a set of guidelines that they may or may not follow. It even says, that there are cases where you may want to diverge from it and when they make sense that's fine. The difference is that this tool checks those for you, so in 99% of the cases people probably won't fill their files with |
Globally I agree with people which think that the There's some options if some error/warning seems inaccurate:
The issue with And if the issue is genuine, the try:
import json
except ImportError:
import simplejson as json # NOQA It was fixed with latest Pyflakes, but the comments For the case reported here ( |
Pep8 now honors the `# noqa` comment, which disables pep8 checks for a certain line (see PyCQA/pycodestyle#180). This is useful for SQLalchemy `== None` filter comparisons and used all quite a bit in Adhocracy model methods, so this should reduce our pep8 error counter quite a bit.
I had this problem with "E221 multiple spaces before operator" because I wanted to:
and it is far more important to have the = signs line up so the decimal places are clear, than it is to comply with the whitespace standard. In my opinion, it would be nice if # noqa worked for any warning, since a clean compliance report is mandatory for us, and turning off compliance for the entire file is the only alternative (which is much worse) in any situation we feel we need # noqa to improve readability. I agree it can be abused, but that is the only situation in which I would use it, and it seems like by using it as intended I should get the best possible result. |
For indirect use of pep8 via flake8, there is an extension which provides this (by fiddling with the default flake8 reporter, so it only works with jobs = 1): I have built a flake8 extension which provides per-file and per-line configuration out of the source tree, by fiddling with the |
I want to reinforce @cbeland's point. There are many cases where columnar alignment provides more clarity than strict compliance with whitespace rules. Reading the comments above, the primary argument against broad application of #noqa is the addition of noise in the source code—a real concern. Another real concern is overuse of global suppression (e.g., via setup.cfg). Many programmers use Eclipse and other IDEs configured to show PEP 8 warnings all the time. (After all, keeping code PEP 8 compliant is usually easier than fixing it later.) However, if global suppression is avoided and local suppression not available, the noise created within the IDE becomes a problem. This situation is compounded on team projects. The only practical team approach to PEP 8 warnings is elimination of all warnings. Without local suppression, global suppression is the only option—and global suppression leads to missed problems. Please enable suppressing all rules, or at least the whitespace rules (and E221 in particular),with #noqa. PEP 8 is the standard for the Python Standard Library. For all other products, let's leave suppression decisions to the product team. |
Closing, see call for pull requests in #480. |
Quoting from https://bitbucket.org/tarek/flake8/issue/37/pep8-doesnt-honor-noqa: " Only the E501 (line length) and the E12* (continuation line) benefit from this feature.", while "# noqa" should work on all kinds of errors and warnings.
Example:
The text was updated successfully, but these errors were encountered: