-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix a false negative for unused-import
#7621
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 a false negative for unused-import
#7621
Conversation
…les & one module uses an import in a type annotation & the same import is unused in a subsequent module. Closes pylint-dev#4150
Pull Request Test Coverage Report for Build 3351949749
💛 - Coveralls |
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.
Great fix !
@@ -1147,6 +1147,7 @@ def leave_module(self, node: nodes.Module) -> None: | |||
return | |||
|
|||
self._check_imports(not_consumed) | |||
self._type_annotation_names = [] |
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.
The fix itself is really simple 😄
Not sure about what to do regarding the release we're aiming. It's a bug but at the same time it was a false negative. Maybe 2.16.0 so we do not raise new messages in a patch. If there's an oversight on our side we don't want cascading patches backport ? |
Co-authored-by: Pierre Sassoulas <[email protected]>
Agreed. Happy to wait until 2.16.0. |
About the primer comment. I notice that the output for Django, Pandas & Sentry is similar to some other open MRs; it doesn't look like it is caused by this MR. |
This comment has been minimized.
This comment has been minimized.
In black I think |
I agree with you & I'm happy to dig into that one; but this false positive isn't created by the current MR. The sample from the import os
from typing import Union
Path = Union[str, "os.PathLike[str]"] |
Ha, something is wrong with the primer then, sorry. |
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.
@mbyrnepr2 can you merge or rebase on main so we launch the new python 3.11 tests please ?
@mbyrnepr2 The message in |
It does seem that way, I agree @DanielNoord but we can also see the same happening on the main branch (before it was merged). Perhaps an issue with the primer? |
Probably! Went through my notifications of last week and noticed this message, but |
Fix a false negative for
unused-import
when linting multiple modules & one module uses an import in a type annotation & the same import is unused in a subsequent module.Type of Changes
Description
Closes #4150