Trying to define a generic using the backporked paramspec in python 3.
from typing import Generic
from typing_extensions import ParamSpec
p = ParamSpec("p")
class X(Generic[p]):
pass
You'll run into an exception thrown by this snippet in the Generic class
if not all(isinstance(p, TypeVar) for p in params):
raise TypeError(
f"Parameters to {cls.__name__}[...] must all be type variables"
)
In 3.10 this has been changed to allow it as defined by PEP 612
https://github.com/python/cpython/blob/3.10/Lib/typing.py#L1260
From the limitations note in the readme I would expect it to work for static typing checking but fail silently at runtime, instead I get an exception that interrupts program flow.
Trying to define a generic using the backporked paramspec in python 3.
You'll run into an exception thrown by this snippet in the Generic class
In 3.10 this has been changed to allow it as defined by PEP 612
https://github.com/python/cpython/blob/3.10/Lib/typing.py#L1260
From the limitations note in the readme I would expect it to work for static typing checking but fail silently at runtime, instead I get an exception that interrupts program flow.