On this page
typing.get_origin
Prev: typing.get_args | Up: typing | Next: typing.get_overloads
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.get_origin
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import get_origin
Signature & Overview
typing.get_origin(tp)
Get the unsubscripted version of a type.
Usage
from typing import get_origin
assert get_origin(list[int]) is list
assert get_origin(dict[str, float]) is dict
assert get_origin(int) is None
Gotchas
- Normalizes
typing.List[int]andlist[int]tolist: ReturnsNonefor unparameterized types.
REPL Inspect
from typing import get_origin
help(get_origin)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/get_args Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/get_overloads 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