On this page
annotationlib.ForwardRef
Prev: annotationlib.Format | Up: annotationlib | Next: annotationlib.get_annotate_from_class_namespace
Rel: annotationlib.annotations_to_string, annotationlib.call_annotate_function, annotationlib.call_evaluate_function, annotationlib.Format
Ref: docs.python.org — annotationlib.ForwardRef
Tags: #public #python3 #stdlib #annotationlib
Import
import annotationlib
from annotationlib import ForwardRef
Signature & Overview
annotationlib.ForwardRef(arg, *, module=None, owner=None, is_argument=True, is_class=False)
Wrapper that holds a forward reference.
Methods & Attributes
ForwardRef.evaluate(self, *, globals=None, locals=None, type_params=None, owner=None, format=<Format.VALUE: 1>)— Evaluate the forward reference and return the value.
Usage
import annotationlib
ref = annotationlib.ForwardRef("Node")
assert ref.__forward_arg__ == "Node"
Gotchas
- Requires Python 3.14+: Returned in place of unresolved names when calling
get_annotations(obj, format=Format.FORWARDREF).
REPL Inspect
from annotationlib import ForwardRef
help(ForwardRef)
Linked from
- tuts/python3/stdlib_module/annotationlib
- tuts/python3/stdlib_module/annotationlib/annotations_to_string
- tuts/python3/stdlib_module/annotationlib/call_annotate_function
- tuts/python3/stdlib_module/annotationlib/call_evaluate_function
- tuts/python3/stdlib_module/annotationlib/Format
- tuts/python3/stdlib_module/annotationlib/get_annotate_from_class_namespace
Related notes
- tuts/python3/stdlib_module/annotationlib/annotations_to_string Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/call_annotate_function Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/call_evaluate_function Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/Format Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/get_annotate_from_class_namespace 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/get_annotations shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/type_repr shared tags: #annotationlib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib