Skip to content
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

Ignores all errors when using noqa: X to only ignore X #44

Closed
blueyed opened this issue May 16, 2018 · 1 comment · Fixed by #134
Closed

Ignores all errors when using noqa: X to only ignore X #44

blueyed opened this issue May 16, 2018 · 1 comment · Fixed by #134

Comments

@blueyed
Copy link

blueyed commented May 16, 2018

When using # noqa: E501 all errors are excluded.

This is due to the code in

if pycodestyle.noqa(self.lines[e.lineno - 1]):
continue
.

pycodestyle.noqa searches for r'# no(?:qa|pep8)\b', which matches # noqa: E501 also.

Without knowing the internals it seems like flake8 itself should include the errors itself - it has logic to ignore only specific errors (https://github.com/PyCQA/flake8/blob/013b925624bd5e4c026e83eb2c6e9f45cafa0dc0/src/flake8/defaults.py#L39-L51).

Example:

s = 'some very, very, very, very, very, very, very, very, very, very, very, very, very, very, very long line'  # noqa: E123

flake8-bugbear should report error t-noqa-colon.py:1:110: B950 line too long (109 > 80 characters) for it, but is silent.

@plinss
Copy link
Contributor

plinss commented Aug 28, 2020

It's considered an anti-pattern for flake8 plugins to filter errors based on # noqa comments. Best practice is to simply send all errors and let flake8 filter them based on user settings, e.g. --disable-noqa should show these errors, but won't because they never get to flake8.

As an aside, this behavior also breaks a plugin of mine: https://github.com/plinss/flake8-noqa, see plinss/flake8-noqa#1

plinss added a commit to plinss/flake8-bugbear that referenced this issue Aug 28, 2020
cooperlees pushed a commit that referenced this issue Oct 19, 2020
* Remove check for # noqa comments
Fixes #44

* remove tests for # noqa behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants