Skip to content
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

Duplicate module names causes Module has no attribute #8220

Closed
plannigan opened this issue Dec 30, 2019 · 2 comments
Closed

Duplicate module names causes Module has no attribute #8220

plannigan opened this issue Dec 30, 2019 · 2 comments

Comments

@plannigan
Copy link

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.

@erictraut
Copy link

This appears to have been fixed at some point. The latest version of mypy no longer emits an error for the code sample.

@hauntsaninja
Copy link
Collaborator

It actually does still repro for me (the repro depends on the name of the file). But this behaviour is desirable.

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants