-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
typing: minor changes #3933
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
typing: minor changes #3933
Conversation
Happy to split this PR up / not squash-merge it, if that makes sense for any reason. |
For py37 and above, this is _GenericAlias, for py36 and below it's _TypeAlias. I don't think we need to make typing.pyi definitions correspond more precisely, but we should avoid leaking a typing.TypeAlias class
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 am slightly worried about the TypeAlias
renaming, but the tests pass and the change is sensible.
Definitely a nervous PR! |
Summary: PEP 560 removed `typing.GenericMeta`, so it was conditionally removed from typeshed by python/typeshed#3933 . However, we rely on that class to be the metaclass of `Generic`, all generic classes, and all protocols. This meant that once typeshed was updated, lots of attributes disappeared. This diff fixes that by special casing it back in. This means we'll erroneously allow users to refer to it, but that's fine for now. Reviewed By: grievejia Differential Revision: D21854250 fbshipit-source-id: 294740a866800b70939f425e8919a3c275b36285
* typing: fix argument names of cast * typing: use private _Alias class For py37 and above, this is _GenericAlias, for py36 and below it's _TypeAlias. I don't think we need to make typing.pyi definitions correspond more precisely, but we should avoid leaking a typing.TypeAlias class
https://www.python.org/dev/peps/pep-0613/ Pep613 for explicit aliases actually relies on |
The TypeAlias removed in this PR is actually unrelated to PEP 613, and is instead meant to reflect typing internals in CPython that were removed (the Given that PEP 613 is accepted, I'd certainly accept a PR on the lines of #4243 (or whatever closes matches the expected implementation of TypeAlias within CPython). This would preferably be gated by the appropriate |
@hauntsaninja Thanks for the quick response, adding this to typing extensions stubs seems reasonable to me. The #4243 PR ends up defining TypeAlias as an object rather than something that can itself be used as a type, so will propose a change there Edit: #4354 |
No description provided.