The Wayback Machine - https://web.archive.org/web/20250609093126/https://github.com/python/cpython/issues/112472
Skip to content

typing.get_args behaviour when using the new 3.12 PEP 695 feature (Type Parameter Syntax) #112472

Open
@Questionsdenombres

Description

@Questionsdenombres

Bug report

Bug description:

Moving some code from 'TypeAlias' to the new PEP 695 'type', I was expecting that typing.get_args would behave the same way.
I am wrong!

But I can't tell if it's a bug or not.
If not, maybe the documentation should tell.

Easy to reproduce:

>>> from typing import get_args, Literal, TypeAlias
>>> T1: TypeAlias = Literal["a", "b"]
>>> get_args(T1)
('a', 'b')
>>> type T2 = Literal["a", "b"]
>>> get_args(T2)
()
>>> Point1: TypeAlias = tuple[float, float]
>>> get_args(Point1)
(<class 'float'>, <class 'float'>)
>>> type Point2 = tuple[float, float]
>>> get_args(Point2)
()

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixesdocsDocumentation in the Doc dirtopic-typing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions