-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 negative reimported
when using an import alias
#4836
Comments
Thank you for your proposition, it makes sense. |
The given example already triggers the message from pathlib import Path
from some_other_lib import CustomPath as Path or from pathlib import Path
import FastAPI.Path as Path Reading the help for def _check_reimport(self, node, basename=None, level=None):
"""check if the import is necessary (i.e. not already done)""" @Pierre-Sassoulas what is your opinion on this? |
reimported
when using an alias
reimported
when using an aliasreimported
when using an alias or false positive that should be a shadowed-import
message instead
I think we should just adjust the docstring and description of the message. I think its intent is pretty clear and also follows what I would expect it to do. That makes this a double issue:
|
Should we also rename the message from |
reimported
when using an alias or false positive that should be a shadowed-import
message insteadreimported
when using an import alias
I think that creates unnecessary churn and |
I'll work on this |
@DanielNoord I think
Which is a lot less problematic than shadowing another import like in: from pathlib import Path
from FastAPI import Path I think we should separate the two use case, with a different message for each, what do you think ? |
I'm not sure. Why would you ever want to enable one of those but not the other? They both warn of significant code smells that seem very related. I'm not against it, but just feel like unnecessary work with minimal benefit. We can focus on many other issues. |
Let's separate the two checks between |
Hello, from some_module import something
...
def bla():
def blabla():
from some_module import something as something_
...
# use blabla In some very rare cases, it may make sense to add another alias in this kind of generated functions. Best regards, |
Current problem
I think it would be nice if Pylint could check if there is same import name from different packages.
For example, in the code below, import order is fine, but the 'Path' imports overlap, causing errors somewhere.
Desired solution
overlapping imports found.
Path
Additional context
No response
The text was updated successfully, but these errors were encountered: