You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After using Concatenate to recursively replace a ParamSpec of a TypeAliasType, another subscription with a type param is possible but the type param is not recognized.
In the last part the following code (C2T = C2[T] # <--- should create a generic), however it's parameters are empty and it cannot be subscripted further:
Consider the following code sample, also availiable on pyright playground
fromtypingimportTypeAliasType, Concatenate, ParamSpec, Any, TypeVarfromcollections.abcimportCallable# (**P) -> strtypeC[**P] =Callable[P, str]
T=TypeVar("T")
P2=ParamSpec("P2")
# (int, **P2) -> strC2=C[Concatenate[int, P2]]
# OK# (T) -> strC1T=C[T]
# (str) -> strC1_str=C1T[str]
# -------- # (int, T) -> strC2T=C2[T] # <--- does not create a genericprint(C2T.__parameters__) # <-- is empty# () # (int, str) -> strC2_str=C2T[str] # <-- cannot be subscripted# TypeError: C[(<class 'int'>, ~T)] is not a generic class
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered:
Daraan
changed the title
TypeAliasType does not recognize type parameter after recusrive use of Concatenate and cannot be subscripted
TypeAliasType does not recognize type parameter after use of Concatenate and cannot be subscripted
Oct 2, 2024
Bug report
Bug description:
After using Concatenate to recursively replace a ParamSpec of a
TypeAliasType
, another subscription with a type param is possible but the type param is not recognized.In the last part the following code (
C2T = C2[T] # <--- should create a generic
), however it's parameters are empty and it cannot be subscripted further:Consider the following code sample, also availiable on pyright playground
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: