Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@Daraan

Description

@Daraan
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.