-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
New semantic analyzer: Name 'MyX' already defined (by an import) #7172
Comments
This looks a bit similar to my issue #7172. It seems to happen sometimes when an object is called like its containing module. |
I'm guessing you meant issue #7203 ? |
Sorry, yes, #7203. |
With 0.720 we instead get a |
A minimized version:
This minimized code I think will actually fail at runtime, though, executing Giving the classes the same name as modules is a worrisome practice, I think? |
@msullivan |
Closing as a duplicate of #7203 |
Are you reporting a bug, or opening a feature request?
Reporting a bug
Please insert below the code you are checking with mypy,
reproducer.zip
I'm somewhat new to mypy so I'm sorry if this is a user error. If nothing else, the error message produced doesn't seem particularly helpful in narrowing down what to do fix it (or what section I might look in in the documentation). This is an error from one of my projects that builds cleanly with
mypy --strict
as well as pylint, pyflakes, etc. (with a few suppressions where the different tools take different views over things). I've reduced it and suitably anonymized it. There is a kind of circular import taking place where I'm importing theMyX
class inMyBase.py
and theMyBase
class fromMyX.py
but it's never previously caused any issues.If I remove the explicit import of
MyX
fromMyDerived2.py
then it obviously fails with:No error with the new semantic analyzer (same as with the old semantic analyzer).
The text was updated successfully, but these errors were encountered: