Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add docs
  • Loading branch information
ilevkivskyi committed May 30, 2019
commit 3b29dae28ee8e28c5ee09fad41e2de9ab19734b8
19 changes: 19 additions & 0 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,25 @@ The module defines the following classes, functions and decorators:
a dictionary constructed by merging all the ``__annotations__`` along
``C.__mro__`` in reverse order.

.. function:: get_origin(typ)
.. function:: get_args(typ)

Provide basic introspection for generic types and special typing forms.

For a typing object of the form ``X[Y, Z, ...]`` these functions return
``X`` and ``(Y, Z, ...)``. If ``X`` is a generic alias for builtin or
Comment thread
ilevkivskyi marked this conversation as resolved.
Outdated
:mod:`collections` class, it gets normalized to the original class.
For unsupported objects return ``None`` and ``()`` correspondingly.
Examples::

assert get_origin(Dict[str, int]) is dict
assert get_args(Dict[int, str]) == (int, str)

assert get_origin(Union[int, str]) is Union
assert get_args(Union[int, str]) == (int, str)

.. versionadded:: 3.8

.. decorator:: overload

The ``@overload`` decorator allows describing functions and methods
Expand Down