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

inspect.get_annotations

Prev: inspect.FullArgSpec | Up: inspect | Next: inspect.getabsfile
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.get_annotations
Tags: #public #python3 #stdlib #inspect


Import

import inspect
from inspect import get_annotations

Signature & Overview

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

Compute the annotations dict for an object.

Usage

import inspect

def fn(x: int) -> str:
    return str(x)

assert inspect.get_annotations(fn) == {"x": int, "return": str}

Gotchas

REPL Inspect

from inspect import get_annotations
help(get_annotations)

Linked from

Related notes