Typing and Generics

typing.get_args

Returns type arguments after substitution, or an empty tuple for unsupported objects. Union and Literal argument order may vary due to caching; do not rely on their order for semantic comparison.

Formal Syntax & Structure

python syntaxpython
typing.get_args(tp)

Parameters & Attributes

NameTypeDescription
tpobjectType expression to inspect.

Return Value

tuple

Typing construct or runtime result as described; static typing rules are not runtime validation.

Working Example

Example Snippetpython
from typing import get_args
alias=dict[str,list[int]]print(get_args(alias) == (str,list[int]))
Python Reference