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

Superfluous and incorrect NQA102 errors #2

Closed
cihati opened this issue Aug 28, 2020 · 8 comments
Closed

Superfluous and incorrect NQA102 errors #2

cihati opened this issue Aug 28, 2020 · 8 comments

Comments

@cihati
Copy link

cihati commented Aug 28, 2020

Hi! First of all, thanks for this great plugin. I tried setting it up right away, but am running into some issues. Specifically, it shows me NQA102 (flake8-noqa) "# noqa: B009" has no matching violations errors for files that doesn't even have any noqa statements inside.

This is what flake8 gives me:

[python] ../.gradle/python/bin/python -m flake8 .
         ./workspace/test_views.py:24:55: NQA102 (flake8-noqa) "# noqa: B010" has no matching violations
         ./backend/scheduler.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/urls.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/tools/contexthelper.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/decorators/test_decorators.py:13:52: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/decorators/test_decorators.py:23:56: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/decorators/test_decorators.py:26:64: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/decorators/__init__.py:13:52: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/decorators/__init__.py:23:56: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/decorators/__init__.py:26:64: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/bigquery/replicators/__init__.py:24:55: NQA102 (flake8-noqa) "# noqa: B010" has no matching violations
         ./backend/components/bigquery/replicators/SQLReplicator.py:24:55: NQA102 (flake8-noqa) "# noqa: B010" has no matching violations
         ./backend/components/bigquery/replicators/IncrementalReplicator.py:24:55: NQA102 (flake8-noqa) "# noqa: B010" has no matching violations
         ./backend/components/mysql/backend.py:24:55: NQA102 (flake8-noqa) "# noqa: B010" has no matching violations
         ./backend/components/mysql/jdbcwrapper.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/mysql/__init__.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/mysql/replicators/FullReplicator.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/mysql/replicators/__init__.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/pythonblock.py:13:52: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/pythonblock.py:23:56: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/pythonblock.py:26:64: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/pythonblock.py:169:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/pythonblock.py:170:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/util.py:13:52: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/util.py:23:56: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/util.py:26:64: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/util.py:169:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/util.py:170:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/constants.py:13:52: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/constants.py:23:56: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/constants.py:26:64: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/constants.py:169:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/constants.py:170:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/__init__.py:13:52: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/__init__.py:23:56: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/__init__.py:26:64: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/__init__.py:169:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tools/__init__.py:170:58: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./backend/components/notebook/tests/test_python_block.py:81:18: NQA102 (flake8-noqa) "# noqa: PT001" has no matching violations
         ./backend/components/notebook/tests/__init__.py:81:18: NQA102 (flake8-noqa) "# noqa: PT001" has no matching violations
         ./backend/exception/__init__.py:81:18: NQA102 (flake8-noqa) "# noqa: PT001" has no matching violations
         ./layer/gql/__init__.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./layer/gql/types.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./layer/gql/schema.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations
         ./layer/gql/test/client.py:151:59: NQA102 (flake8-noqa) "# noqa: B009" has no matching violations

But here are all files with B009:

platform/backend/components/notebook/pythonblock.py:        kernel["load"] = getattr(storage_proxy, "load")  # noqa: B009
platform/backend/components/notebook/pythonblock.py:        kernel["save"] = getattr(storage_proxy, "save")  # noqa: B009
platform/backend/decorators/test_decorators.py:        self.assertTrue(getattr(func, "is_rest"))  # noqa: B009
platform/backend/decorators/test_decorators.py:        self.assertTrue(getattr(func, "is_exported"))  # noqa: B009
platform/backend/decorators/test_decorators.py:            parameter_label, getattr(func, "parameter_label")  # noqa: B009
platform/backend/scheduler.py:        backend_build_method = getattr(backend, "build")  # noqa: B009

Any ideas?

@plinss
Copy link
Owner

plinss commented Aug 28, 2020

Thanks for the report, can you give example code that generates the NQA102 errors that don't have don't have # noqa comments? I don't need the whole file, but a few lines before and after would be helpful as well.

Looking at the bugbear code it appears that it doesn't send violations for line based checks with # noqa comments (but should send them for AST based checks), so it will also suffer from the same issue as #1 for those. I left a comment on an existing issue in bugbear about this.

@MrkGrgsn
Copy link

MrkGrgsn commented Feb 4, 2021

I noticed the same issue today. It looks like a reporting issue rather than an issue with the checks. Here is one example.

membership.py:307:35: NQA102 (flake8-noqa) "# noqa: N805" has no matching violations
membership.py:388:35: NQA102 (flake8-noqa) "# noqa: N805" has no matching violations
project.py:307:35: NQA102 (flake8-noqa) "# noqa: N805" has no matching violations
project.py:388:35: NQA102 (flake8-noqa) "# noqa: N805" has no matching violations
propose.py:307:35: NQA102 (flake8-noqa) "# noqa: N805" has no matching violations
propose.py:388:35: NQA102 (flake8-noqa) "# noqa: N805" has no matching violations

The first two lines are correct but the subsequent lines are incorrect. They appear to be repeated reporting of the first file's errors attributed to the other files - notice that the line numbers are the same across all 3 files?

@plinss
Copy link
Owner

plinss commented Feb 4, 2021

Interesting, can you give an example file that has the errors? I don't need your entire source files, just enough to reproduce the error.

@MrkGrgsn
Copy link

MrkGrgsn commented Feb 4, 2021

A simple example is a module with just this:

def my_func():
    pass  # noqa: W605

Any file checked after will have the same error reported, even if it's empty.

Edit: add environment info

$ flake8 --version
3.8.3 (flake8-noqa: 1.0.5, mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0)
CPython 3.6.12 on Linux

@plinss
Copy link
Owner

plinss commented Feb 4, 2021

Thanks for the info, found the issue and fixed it. A new version will be available shortly.

While I was there I found some other tweaks I never landed, so picked up those too.

@plinss plinss closed this as completed in df1631f Feb 4, 2021
@MrkGrgsn
Copy link

MrkGrgsn commented Feb 4, 2021

Thanks @plinss it is working very nicely now.

@jace
Copy link

jace commented Jun 23, 2021

I'm experiencing the same with flake8-noqa==1.1.0 (from PyPI). Code:

    print(f"Downloading {filename}...")  # NOQA: T001

flake8 (with flake8-print==4.0.0, which causes the T001):

file.py:135:42: NQA102 "# NOQA: T001" has no matching violations

@jace
Copy link

jace commented Jun 23, 2021

Oh I see the flake8-print issue has been reported in #1 already. I'm also experiencing this with codes B902 (flake8-blind-except), A003 (flake8-builtins), S105 and S106 (flake8-bandit).

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

No branches or pull requests

4 participants