On this page
typing.ForwardRef
Prev: typing.final | Up: typing | Next: typing.FrozenSet
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.ForwardRef
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import ForwardRef
Signature & Overview
typing.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
from typing import ForwardRef
ref = ForwardRef("Node")
assert ref.__forward_arg__ == "Node"
Gotchas
- Usually created automatically from string annotations (
"Node"): Rarely instantiated directly unless building runtime typing utilities.
REPL Inspect
from typing import ForwardRef
help(ForwardRef)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/final_func Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/FrozenSet 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