On this page
typing.TypeAliasType
Prev: typing.TextIO | Up: typing
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.TypeAliasType
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import TypeAliasType
Signature & Overview
typing.TypeAliasType(...)
Type alias.
Usage
from typing import TypeAliasType
# Python 3.12+: runtime object created by `type Vector = list[float]`
Vector = TypeAliasType("Vector", list[float])
assert Vector.__name__ == "Vector" and Vector.__value__ == list[float]
Gotchas
- Requires Python 3.12+: Prefer the
type Vector = list[float]statement syntax;TypeAliasTypeis its runtime representation.
REPL Inspect
from typing import TypeAliasType
help(TypeAliasType)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/TextIO Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncContextManager shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncGenerator shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncIterable shared tags: #stdlib, #typing