@@ -93,9 +93,13 @@ This is equivalent to omitting the generic notation and just saying
9393User-defined generic types
9494--------------------------
9595
96- You can define a user-defined class as generic by including a ``Generic ``
97- base class, either explicitly or implicitly via the ``Protocol[T] ``
98- shorthand for :ref: `generic protocols<generic-protocols> `. Example::
96+ You can define a user-defined class as generic in three ways: by including a
97+ ``Generic `` base class, by using the new generic class syntax in Python 3.12
98+ and higher, or by including a ``Protocol `` base class parameterized with type
99+ variables. The third approach also marks the class as a protocol - see
100+ :ref: `generic protocols<generic-protocols> ` for more information.
101+
102+ Example using ``Generic ``::
99103
100104 from typing import TypeVar, Generic
101105 from logging import Logger
@@ -119,14 +123,14 @@ shorthand for :ref:`generic protocols<generic-protocols>`. Example::
119123 def log(self, message: str) -> None:
120124 self.logger.info('{}: {}'.format(self.name, message))
121125
122- Or, in Python 3.12 and higher, by using the new syntax for generic
123- classes::
126+ Or, using the new generic class syntax::
124127
125128 class LoggedVar[T]:
126129 # methods as in previous example
127130
128131This implicitly adds ``Generic[T] `` as a base class and type checkers
129- should treat the two largely equivalently (except for variance, see below).
132+ should treat the two definitions of ``LoggedVar `` largely equivalently (except
133+ for variance, see below).
130134
131135``Generic[T] `` as a base class defines that the class ``LoggedVar ``
132136takes a single type parameter ``T ``. This also makes ``T `` valid as
0 commit comments