summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorkj <28750310+Fidget-Spinner@users.noreply.github.com>2020-10-31 06:02:38 (GMT)
committerGitHub <noreply@github.com>2020-10-31 06:02:38 (GMT)
commitbcbf758476c1148993ddf4b54d3f6169b973ee1c (patch)
treecfc8e64da795dcd1f2db82fbf80866b3292720c9 /Doc
parent43ca084c88d1e46a44199f347c72e26db84903c9 (diff)
downloadcpython-bcbf758476c1148993ddf4b54d3f6169b973ee1c.zip
cpython-bcbf758476c1148993ddf4b54d3f6169b973ee1c.tar.gz
cpython-bcbf758476c1148993ddf4b54d3f6169b973ee1c.tar.bz2
bpo-42198: Document __new__ for types.GenericAlias (GH-23039)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/stdtypes.rst3
-rw-r--r--Doc/library/types.rst13
2 files changed, 14 insertions, 2 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 3fd94ea..09477e6 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -4793,7 +4793,8 @@ The ``GenericAlias`` object acts as a proxy for :term:`generic types
of a generic which provides the types for container elements.
The user-exposed type for the ``GenericAlias`` object can be accessed from
-:data:`types.GenericAlias` and used for :func:`isinstance` checks.
+:class:`types.GenericAlias` and used for :func:`isinstance` checks. It can
+also be used to create ``GenericAlias`` objects directly.
.. describe:: T[X, Y, ...]
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index 0072055..ad40a9f 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -262,11 +262,22 @@ Standard names are defined for the following types:
.. versionadded:: 3.10
-.. data:: GenericAlias
+.. class:: GenericAlias(t_origin, t_args)
The type of :ref:`parameterized generics <types-genericalias>` such as
``list[int]``.
+ ``t_origin`` should be a non-parameterized generic class, such as ``list``,
+ ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of
+ length 1) of types which parameterize ``t_origin``::
+
+ >>> from types import GenericAlias
+
+ >>> list[int] == GenericAlias(list, (int,))
+ True
+ >>> dict[str, int] == GenericAlias(dict, (str, int))
+ True
+
.. versionadded:: 3.9
.. data:: Union