-
-
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
name.py
used as module instead of name
module directory
#7711
Comments
Sorry, but I am a bit lost. Could you please show the fill directory tree, content of the files, and the exact command you use to run mypy? In any case, the fact that this work at runtime is not a justification, since |
The directory structure (simplified from a larger project).
Inside |
I invoke:
Or with mypy 0.730 |
OK, I see. IIUC you want to have both The bug here is that mypy is silent about the duplicate module situation (unlike if you directly pass |
Is this a limitation of Python itself? I can understand why mypy behaves this way, but wondering if whether it's also an undefined situation in the Python runtime and I'm getting lucky that it works. |
This is mypy-specific, but in general I personally consider this a dangerous style since it can cause surprises during refactoring (similar to why I think absolute imports are better than relative ones). |
I have a module named
mdl
with the below__init__.py
(The contents don't actually matter).Then I have a file called
mdl.py
:mypy
produces the error:If I rename the file to
anything_else.py
this error doesn't happen.It appears as though mypy is resolving the
mdl
import to the filemdl.py
instead of themdl
module directory. Since the Python interpreter resolve the names as I intended, I'd assumemypy
would as well.The text was updated successfully, but these errors were encountered: