-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add missing dunder attributes for TypeAliasType instances #470
Add missing dunder attributes for TypeAliasType instances #470
Conversation
From what I see In 3.9 it will raise an TypeError in belows test as it tries to subscript the With def test_callable_with_concatenate(self):
P = ParamSpec('P')
CallableP = TypeAliasType("CallableP", Callable[P, Any], type_params=(P,))
callable_concat = CallableP[Concatenate[int, P]]
self.assertEqual(callable_concat.__parameters__, (P,))
concat_usage = callable_concat[str] # <-- will fail for 3.9 with GenericAlias |
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.
Thanks! I pushed a slightly different solution to your PR branch (using a _GenericAlias
subclass) so that all the tests would pass on py38 and py39 as well. Your tests were fantastic; they really helped to see all aspects of the problem!
Adresses: #449
As @JelleZijlstra mentioned that GenericAlias can be used to address #469.
GenericAlias
seems promising, however I am not sure what greater underlying changes this swap could maybe cause.Currently I am still tracing some errors and I want to make sure I am not regressing some cases that currently are not covered by tests. This is also a reason this is currently only used for 3.10+.
See below I think using it in 3.9 will cause more harm than benefits.