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

typing.get_type_hints

Prev: typing.get_protocol_members | Up: typing | Next: typing.IO
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.get_type_hints
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import get_type_hints

Signature & Overview

typing.get_type_hints(obj, globalns=None, localns=None, include_extras=False, *, format=None)

Return type hints for an object.

Usage

from typing import get_type_hints

def add(a: int, b: int) -> int:
    return a + b

assert get_type_hints(add) == {"a": int, "b": int, "return": int}

Gotchas

REPL Inspect

from typing import get_type_hints
help(get_type_hints)

Linked from

Related notes