Version-Specific Features

Python 3.14 — Annotation inspection formats

Inspect annotations using runtime values, forward-reference objects or source-like strings. Evaluation may execute arbitrary annotation expressions; inspect only trusted objects. STRING is not a guarantee of safe handling of arbitrary objects. Requires Python 3.14 or the relevant build; example is not executed locally.

Formal Syntax & Structure

python syntaxpython
annotationlib.get_annotations(obj, *, format=Format.VALUE)

Return Value

Feature-specific

No single return type; see the example and feature description.

Working Example

Example Snippetpython
from annotationlib import get_annotations, Formatdef f(x: Missing): passprint(get_annotations(f, format=Format.STRING))
Python Reference