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
Fix #3299 false positives with names in string literal type annotations #7400
Conversation
This comment has been minimized.
This comment has been minimized.
… typing.Literal arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, LGTM, I have only a small question.
tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py39.py
Show resolved
Hide resolved
Pull Request Test Coverage Report for Build 2987707904
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @lggruspe.
Some minor stylistic changes but the changes itself look very good!
tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py
Show resolved
Hide resolved
tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py
Outdated
Show resolved
Hide resolved
tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py
Show resolved
Hide resolved
tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py310.py
Show resolved
Hide resolved
tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py38.py
Show resolved
Hide resolved
tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py39.py
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason the coverage is going down, but I think that is unrelated to the changes here. Probably coveralls screwing something up.
Thanks @lggruspe! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @lggruspe. The changes look good, and the primer results warm my heart.
… annotations (pylint-dev#7400) Don't emit 'unused-variable' or 'unused-import' on names in string literal type annotations (pylint-dev#3299) Don't treat strings inside typing.Literal as names
Type of Changes
Description
Closes #3299
Changes:
VariablesChecker
now checks for possible names inConst
strings that appear in a typing annotation context. This fixes some false positives forunused-import
andunused-variable
.Const
s used as args totyping.Literal
aren't treated as names."os.PathLike[str]"
or"graphlib.TopologicalSorter[T]"
now work