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

annotationlib.get_annotations

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


Import

import annotationlib
from annotationlib import get_annotations

Signature & Overview

annotationlib.get_annotations(obj, *, globals=None, locals=None, eval_str=False, format=<Format.VALUE: 1>)

Compute the annotations dict for an object.

Usage

import annotationlib

def add(a: int, b: int) -> int: return a + b
assert annotationlib.get_annotations(add, format=annotationlib.Format.VALUE) == {"a": int, "b": int, "return": int}

Gotchas

REPL Inspect

from annotationlib import get_annotations
help(get_annotations)

Linked from

Related notes