Typing and Generics
typing.TypeAlias
Explicitly identifies an assignment as a type alias for static tools. Deprecated since 3.12 in favor of the type statement; the assignment itself still binds the underlying object. The type statement creates a different runtime alias object; migrate deliberately.
Formal Syntax & Structure
python syntaxpython
Name: typing.TypeAlias = TReturn Value
type qualifier
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import TypeAlias, get_args
UserIds: TypeAlias = list[int]print((UserIds == list[int], get_args(UserIds)[0] is int))