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

False-positive error for Final if it's aliased #316

Closed
AlexWaygood opened this issue Jan 8, 2023 · 3 comments · Fixed by #326
Closed

False-positive error for Final if it's aliased #316

AlexWaygood opened this issue Jan 8, 2023 · 3 comments · Fixed by #326
Labels

Comments

@AlexWaygood
Copy link
Collaborator

AlexWaygood commented Jan 8, 2023

flake8-pyi currently emits a false-positive error for this code, which should be fine:

from typing_extensions import Final as _Final

CONSTANT: _Final = 5

This might be tricky to fix, since we don't currently track whether imports are aliased at all. Came up in python/typeshed#9470

@Avasam
Copy link
Contributor

Avasam commented Jan 9, 2023

Similarly, Y036 (Badly defined __exit__ method) will false-positive with a TypeAlias of object (ie: _Unused: TypeAlias = object)

@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jan 9, 2023

Similarly, Y036 (Badly defined exit method) will false-positive with a TypeAlias of object (ie: _Unused: TypeAlias = object)

Sure, but I'm gonna say I definitely don't want us to try and fix that one. It's ~reasonable to argue that we should track whether imports are aliased. But constructing a "poor man's symbol table" for the entire module would require whole new level of complexity 😃 it's important to remember that we're just a dumb linter, we're not a type checker 😁

@Avasam
Copy link
Contributor

Avasam commented Jan 9, 2023

it's important to remember that we're just a dumb linter, we're not a type checker

Right, you don't have easy access to that kind of information 😅

AlexWaygood added a commit to AlexWaygood/flake8-pyi that referenced this issue Jan 16, 2023
JelleZijlstra pushed a commit that referenced this issue Jan 16, 2023
)

Fixes #316, among other things.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants