Skip to the content.

Type Hint

An annotation that specifies the expected type for:

Use Case

Typeshed Stub

pip install mypy

pip install types-xxx

See typeshed on GitHub and mypy on GitHub.

Backward Compability

pip install typing-extensions

See typing-extensions package on PyPI.

typing.get_type_hints()

Type hints of global variables, class attributes, and functions, but not local variables, can be accessed using typing.get_type_hints().

typing.get_type_hints(obj, globalns=None, localns=None, include_extras=False) -> dict

Return a dictionary containing type hints for a function, method, module or class object.

This is often the same as obj.__annotations__. In addition, forward references encoded as string literals are handled by evaluating them in globalns and localns namespaces.

References