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

flake8-noqa reports unused noqa comments in generated protobuf stubs #413

Closed
AlexWaygood opened this issue Aug 29, 2022 · 3 comments · Fixed by #418
Closed

flake8-noqa reports unused noqa comments in generated protobuf stubs #413

AlexWaygood opened this issue Aug 29, 2022 · 3 comments · Fixed by #418

Comments

@AlexWaygood
Copy link

AlexWaygood commented Aug 29, 2022

I recently tried running flake8 on typeshed with the flake8-noqa plugin installed, to see if we had any unnecessary noqa comments lying around. Among several other hits (some of which were fixed in python/typeshed#8639), flake8-noqa reported the following:

stubs\protobuf\google\protobuf\struct_pb2.pyi:55:133: NQA102 "# noqa: F821" has no matching violations
stubs\protobuf\google\protobuf\type_pb2.pyi:56:127: NQA102 "# noqa: F821" has no matching violations

These noqa comments do indeed seem to be unnecessary when using the latest version of flake8.

flake8-relevant details of my local environment:

flake8==5.0.4
flake8-bugbear==22.7.1
flake8-noqa==1.2.9
flake8-pyi==22.8.1

(This doesn't need to be high priority. For several other reasons, I think it's unlikely we'll be able to enable flake8-noqa's NQA102 in CI at typeshed right now, anyway 🙂)

@nipunn1313
Copy link
Owner

The #noqa was for PyCQA/flake8-pyi#278 - maybe flake8 fixed it? Will poke around when I get some time.

@nipunn1313
Copy link
Owner

Interestingly, it seems like flake8 understands forward references if the class is at module scope.

However if the class is an inner class within another class, then flake8 does not understand the forward reference.

I can probably update mypy-protobuf to emit a #noqa in the inner scope ones but not the module scope ones.

Still seems like a bug in flake8! (PyCQA/flake8-pyi#278)

@AlexWaygood
Copy link
Author

Thanks for the quick response on this @nipunn1313!

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