You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate module names causes Module has no attribute #8220
This is a bug report. There was a regression recently that caused mypy to start raising error where it did not in the past.
Example:
Save the following code at pathlib.py.
import pathlib
p = pathlib.Path(".")
print(p)
With the latest mypy, this fails.
$ mypy --version
mypy 0.761
$ mypy pathlib.py
pathlib.py:3: error: Module has no attribute "Path"
Found 1 error in 1 file (checked 1 source file)
However, it used to work:
$ mypy --version
mypy 0.720
$ mypy pathlib.py
$
Note: This code won't run, but I was having trouble making a simple example to reproduce the issue I was seeing. The actually case where this happened does work and was a sub-module within a project that was named the same as a 3rd part module it was wrapping.
Activity
erictraut commentedon Aug 11, 2023
This appears to have been fixed at some point. The latest version of mypy no longer emits an error for the code sample.
hauntsaninja commentedon Aug 12, 2023
It actually does still repro for me (the repro depends on the name of the file). But this behaviour is desirable.