-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Change prefix for _importlib_modulespec names #1127
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
Conversation
72b69c9
to
c63f855
Compare
Next commit would break mypy unless python/mypy#3107 is merged. Note: I wasn't sure about this line in 2/abc.pyi:
which I changed to
I'm afraid I might be breaking something even though the tests pass. Also, werkzeug stubs had:
I removed them, but I also suspect they may serve some non-obvious purpose. |
stdlib/2/tokenize.pyi
Outdated
@@ -102,15 +103,15 @@ chain = ... # type: type | |||
double3prog = ... # type: type | |||
endprogs = ... # type: Dict[str, Any] | |||
pseudoprog = ... # type: type | |||
re = ... # type: module | |||
re = ... # type: ModuleType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't be here at all. (I'm guessing tokenize just imports re.)
stdlib/3/_importlib_modulespec.pyi
Outdated
@@ -9,6 +9,8 @@ from abc import ABCMeta | |||
import sys | |||
from typing import Any, Optional | |||
|
|||
MYPY_MODULE = 'importlib.machinery' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go down this route, we should prefix it with _
to make clear that this name isn't actually part of this module. However, I'd prefer to just hardcode the location of ModuleType in mypy and not add special handling in typeshed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an opinion on this, I would be happy to hard code it in mypy. Just wasn't sure if it's ok given that it's hard to find later when more circular import definitions happen.
I replaced the MYPY_MODULE with hard-coded remapping; so this PR simply replaces |
d247130
to
04fee7c
Compare
Superceded by #1156 |
(Not ready for merging)
This PR is meaningless without python/mypy#3107; if that one is approved, this would fix the type reported for modules from
_importlib_modulespec.ModuleType
totypes.ModuleType
. (There is no dependency in the other direction.)This PR is related to python/mypy#3106.