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
documented return value of get_origin for ParamSpecArgs and `Para…
…mSpecKwargs` instances
  • Loading branch information
chgnrdv committed Apr 30, 2023
commit 6009b6be76c709b8904b227d176f0b538977b997
5 changes: 5 additions & 0 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2902,12 +2902,17 @@ Introspection helpers
Get the unsubscripted version of a type: for a typing object of the form
``X[Y, Z, ...]`` return ``X``. If ``X`` is a generic alias for a builtin or
:mod:`collections` class, it gets normalized to the original class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add that for ParamSpecArgs and Kwargs, it returns the underlying ParamSpec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

If ``X`` is an instance of :class:``ParamSpecArgs`` or :class:``ParamSpecKwargs``,
return the underlying :class:``ParamSpec``.
Return ``None`` for unsupported types.
Examples::

assert get_origin(str) is None
assert get_origin(Dict[str, int]) is dict
assert get_origin(Union[int, str]) is Union
P = ParamSpec('P')
assert get_origin(P.args) is P
assert get_origin(P.kwargs) is P

.. versionadded:: 3.8

Expand Down