Skip to content

Commit 8cd14d9

Browse files
committed
Refine type parameter ordering section
1 parent ed282b5 commit 8cd14d9

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

docs/spec/generics.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,16 @@ Also consider the following example::
484484

485485
In this case ``MyDict`` has a single type parameter, ``T``.
486486

487+
Type parameter ordering
488+
-----------------------
489+
490+
For classes using the Python 3.12 generic class syntax, the type
491+
parameter order is determined by the order of parameters in the type
492+
parameter list::
493+
494+
class NewStyle[T1, T2]:
495+
...
496+
487497
Type variables are applied to the defined class in the order in which
488498
they first appear in any generic base classes::
489499

@@ -541,14 +551,7 @@ affect type parameter ordering::
541551
class BareProtoChild(ProtoBase[T1, T2], Protocol):
542552
...
543553

544-
In both examples above, the type parameter order is ``T1``, ``T2``.
545-
546-
For classes using the Python 3.12 generic class syntax, the type
547-
parameter order is determined by the order of parameters in the type
548-
parameter list::
549-
550-
class NewStyle[T1, T2]:
551-
...
554+
In all of the examples above, the type parameter order is ``T1``, ``T2``.
552555

553556
A type checker should report an error when the type variable order is
554557
inconsistent::

0 commit comments

Comments
 (0)