-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Names are re-exported from stubs #2927
Comments
Strange Why would that work? Normally when you do "from X import Y" inside
a stub, Y is not exported further. Is this not working in the case that X
is typing?
|
Hm... I just tried this with other modules, and it looks like names from stubs are always exported further by stubs. Namely I have this:
Then |
From what I read in But I think names imported in stubs should be never implicitly re-exported (not only when used with |
What if you rename tsta.py to tsta.pyi? |
The behavior is the same as with I am almost sure now that the problem is |
I'm pretty sure that @ilevkivskyi is right and only |
The reason for the current behavior is that |
Wow. I've always believed that you had to write `from X import Y as Y` in a
stub in order to explicitly export Y. That's also what PEP 484 says AFAICT.
But you're right it seems to work only for 'import *'.
|
OK, then I will make a PR that will ensure this behaviour also for |
Fixes #2927 PEP 484 specifies that only names imported as ``from mod import name as name`` should be re-exported. However, mypy didn't follow this rule so that this code passed without errors but obviously fails at runtime: from collections import TypeVar from weakref import Generic from getopt import List T = TypeVar('T') class C(Generic[T], List[int]): ... This PR makes all these errors.
This code passes silently, but obviously fails at runtime:
The text was updated successfully, but these errors were encountered: