File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -4760,7 +4760,8 @@ The ``GenericAlias`` object acts as a proxy for :term:`generic types
4760
4760
of a generic which provides the types for container elements.
4761
4761
4762
4762
The user-exposed type for the ``GenericAlias `` object can be accessed from
4763
- :data: `types.GenericAlias ` and used for :func: `isinstance ` checks.
4763
+ :class: `types.GenericAlias ` and used for :func: `isinstance ` checks. It can
4764
+ also be used to create ``GenericAlias `` objects directly.
4764
4765
4765
4766
.. describe :: T[X, Y, ...]
4766
4767
Original file line number Diff line number Diff line change @@ -242,11 +242,22 @@ Standard names are defined for the following types:
242
242
Defaults to ``None ``. Previously the attribute was optional.
243
243
244
244
245
- .. data :: GenericAlias
245
+ .. class :: GenericAlias(t_origin, t_args)
246
246
247
247
The type of :ref: `parameterized generics <types-genericalias >` such as
248
248
``list[int] ``.
249
249
250
+ ``t_origin `` should be a non-parameterized generic class, such as ``list ``,
251
+ ``tuple `` or ``dict ``. ``t_args `` should be a :class: `tuple ` (possibly of
252
+ length 1) of types which parameterize ``t_origin ``::
253
+
254
+ >>> from types import GenericAlias
255
+
256
+ >>> list[int] == GenericAlias(list, (int,))
257
+ True
258
+ >>> dict[str, int] == GenericAlias(dict, (str, int))
259
+ True
260
+
250
261
.. versionadded :: 3.9
251
262
252
263
You can’t perform that action at this time.
0 commit comments