PyDocs

Nav

Development Tools

evaluate_forward_ref

typing

function · Added in 3.14 (source)
  • evaluate_forward_ref(forward_ref, *, owner=None, globals=None, locals=None, type_params=None, format=annotationlib.Format.VALUE)
Evaluate a forward reference as a type hint.

This is similar to calling the ForwardRef.evaluate() method,
but unlike that method, evaluate_forward_ref() also
recursively evaluates forward references nested within the type hint.

*forward_ref* must be an instance of ForwardRef. *owner*, if given,
should be the object that holds the annotations that the forward reference
derived from, such as a module, class object, or function. It is used to
infer the namespaces to use for looking up names. *globals* and *locals*
can also be explicitly given to provide the global and local namespaces.
*type_params* is a tuple of type parameters that are in scope when
evaluating the forward reference. This parameter should be provided (though
it may be an empty tuple) if *owner* is not given and the forward reference
does not already have an owner set. *format* specifies the format of the
annotation and is a member of the annotationlib.Format enum, defaulting to
VALUE.
0 Examples
No examples for typing/evaluate_forward_ref.
See Also
No see-alsos for typing/evaluate_forward_ref
0 Notes
No notes for evaluate_forward_ref