annotationlib.type_repr
Prev: annotationlib.get_annotations | Up: annotationlib
Rel: annotationlib.annotations_to_string, annotationlib.call_annotate_function, annotationlib.call_evaluate_function, annotationlib.Format
Ref: docs.python.org — annotationlib.type_repr
Tags: #public #python3 #stdlib #annotationlib
Import
import annotationlib
from annotationlib import type_repr
Signature & Overview
annotationlib.type_repr(value)
Convert a Python value to a format suitable for use with the STRING format.
Usage
import annotationlib
assert annotationlib.type_repr(int) == "int"
assert annotationlib.type_repr(list[str]) == "list[str]"
Gotchas
- Requires Python 3.14+: Formats a runtime type object cleanly without
<class '...'>wrappers.
REPL Inspect
from annotationlib import type_repr
help(type_repr)
Linked from
Related notes
- tuts/python3/stdlib_module/annotationlib/get_annotations Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/annotationlib/annotations_to_string Linked here; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/call_annotate_function Linked here; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/call_evaluate_function Linked here; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/Format Linked here; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/ForwardRef shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/get_annotate_from_class_namespace shared tags: #annotationlib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib