Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.9k
genericGenericAlias
#13941
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
genericGenericAlias
#13941
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Diff frommypy_primer, showing the effect of this PR on open source code: pydantic (https://github.com/pydantic/pydantic)- pydantic/v1/typing.py:47: error: Incompatible types in assignment (expression has type "tuple[()]", variable has type "type[GenericAlias]") [assignment]+ pydantic/v1/typing.py:47: error: Incompatible types in assignment (expression has type "tuple[()]", variable has type "type[GenericAlias[_OriginT_co]]") [assignment]discord.py (https://github.com/Rapptz/discord.py)- discord/ext/commands/converter.py:1119: error: Return type "Greedy[T]" of "__class_getitem__" incompatible with return type "GenericAlias" in supertype "list" [override]+ discord/ext/commands/converter.py:1119: error: Return type "Greedy[T]" of "__class_getitem__" incompatible with return type "GenericAlias[type | TypeAliasType]" in supertype "list" [override] |
What problem does this solve? The class is not generic at runtime and I think pretending it is is likely to cause more confusion than it's worth. |
It makes it possible to annotate Lines 936 to 937 in8b877a6
Runtime-typing libraries that only accept subscripted types could also benefit from this: If e.g.
I suppose that's a bit of a chicken/egg story. And in my experience, typeshed usually takes the lead in these kinds of things, and cpython then follows (e.g.#13760). |
I suppose that theoretically speaking (i.e. ignoring type-checkers), this brings support for higher-kinded typing 🤔.