Skip to content

TypeAliasType with should also raise an error if non-default type parameter follows default type parameter #124787

Closed
@Daraan

Description

@Daraan

Bug report

Bug description:

The following statement is invalid:

type X[T_default=int, T] = (T_default, U) 
# SyntaxError: non-default type parameter 'T' follows default type parameter

However, writing it as a TypeAliasType is possible. The following should likely raise an error as well to mimic this behavior:

from typing import TypeAliasType, TypeVar
T = TypeVar('T')
T_default = TypeVar("T_default", default=int)
TypeAliasType("TupleT_default_reversed", tuple[T_default, T], type_params=(T_default, T))
print("OK")

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions