How to annotate generic class with ParamSpec argument in older versions
#908
Unanswered
bryanforbes
asked this question in
Q&A
Replies: 3 comments 5 replies
|
This line: class IntsInvoker(Invoker[[int, int]]):must be spelled like this:
|
3 replies
|
Looks like we skipped this in typing-extensions tests: https://github.com/python/typing/blob/master/typing_extensions/src_py3/test_typing_extensions.py#L2075. I don't recall how hard we tried to get this to work, but perhaps it's possible with some more black magic in typing_extensions. |
1 reply
|
The solutions in https://mypy.readthedocs.io/en/latest/runtime_troubles.html#using-classes-that-are-generic-in-stubs-but-not-at-runtime should be applicable here as well |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Let's say I have something along these lines (this is completely contrived) and I'm using Python 3.9:
According to PEP-612, the above should be valid. However, if I run this using Python 3.9 or lower, it will crash with:
I should also be able to define
IntsInvokerin this way:However that also crashes using Python 3.9 or lower:
What is the proper way to define
IntsInvokerso it will work in Python 3.9 and 3.10?All reactions