On this page
  1. annotationlib.call_annotate_function
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

annotationlib.call_annotate_function

Prev: annotationlib.annotations_to_string | Up: annotationlib | Next: annotationlib.call_evaluate_function
Rel: annotationlib.annotations_to_string, annotationlib.call_evaluate_function, annotationlib.Format, annotationlib.ForwardRef
Ref: docs.python.org — annotationlib.call_annotate_function
Tags: #public #python3 #stdlib #annotationlib


Import

import annotationlib
from annotationlib import call_annotate_function

Signature & Overview

annotationlib.call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False)

Call an annotate function. annotate functions are normally generated by the compiler to defer the evaluation of annotations. They can be called with any of the format arguments in the Format enum, but

Usage

import annotationlib

def fn(x: int) -> str: return str(x)
ann = annotationlib.call_annotate_function(fn.__annotate__, annotationlib.Format.VALUE)
assert ann == {"x": int, "return": str}

Gotchas

REPL Inspect

from annotationlib import call_annotate_function
help(call_annotate_function)

Linked from

Related notes