Skip to content

TypeAliasType does not recognize type parameter after use of Concatenate and cannot be subscripted#124904

@Daraan

Description

@Daraan

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

fromtypingimportTypeAliasType, Concatenate, ParamSpec, Any, TypeVarfromcollections.abcimportCallable# (**P) -> str type C[**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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions