-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
'from .foo import *' introduces 'foo' as symbol that mypy doesn't recognise #4140
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
Comments
I cannot repro this at all. What mypy version are you using? What's in your
mypy.ini?
|
I can reproduce this on both mypy 0.530 and 0.540. I don't have a mypy.ini.
|
I still can't repro it. I wonder... Do you have a file named |
Nope, empty directory and PYTHONPATH isn't set.
I'm using mypy in a Conda environment on OS X. I don't have yaml or pyyaml installed in that environment. Interestingly, I can't reproduce this with pyvenv:
|
Then it means this is a broken installation with old typeshed, try installing with |
@Wilfred If Ivan's suggestion works, I would love to understand how your system got into this state (and what exactly that state was -- seems an old typeshed is taking precedence over the correct one). Perhaps before deleting anything could you run |
Running mypy with
|
This rather looks like it's using a copy of typeshed from inside mypy itself. Are there any other tests you'd like me to run? |
The typeshed inside my conda env does indeed have yaml/error.pyi:
I've also confirmed that creating a fresh conda env does not reproduce this issue. |
So does Ivan's suggestion solve your problem or not? The key bit of information is whether yaml/init.pyi contains a If you really can't fix this problem in your environment, a workaround is to add |
I'm not sure how my conda environment got into this state, so I'm going to close this. If I encounter it again, I'll reopen with reproduction steps. I'm happily using mypy in other virtualenvs/conda environments. |
The typeshed definition for
yaml/__init__.pyi
contains the following (src):This has two side effects: it adds every symbol
foo
inyaml/error.py
asyaml.foo
. However, it also definesyaml.error
.I believe this is why the mypy complains about the following correct code:
Oddly, I can't reproduce this on Python 3. The following code does not produce a type error:
The text was updated successfully, but these errors were encountered: