Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy