-
Notifications
You must be signed in to change notification settings - Fork 290
Closed
Description
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]):
passYou'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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels