@@ -289,7 +289,8 @@ The following directives are provided for module and class contents:
289
289
.. py:exception:: name[type parmeters](parameters)
290
290
291
291
Describes an exception class. The signature can, but need not include
292
- parentheses with constructor arguments.
292
+ parentheses with constructor arguments, or may optionally include type
293
+ parameters (see :pep: `695 `).
293
294
294
295
.. rubric :: options
295
296
@@ -379,9 +380,9 @@ The following directives are provided for module and class contents:
379
380
.. rst:directive:option:: single-line-type-parameter-list
380
381
:type: no value
381
382
382
- Ensure that the class constructor's type parameters are emitted on a
383
- single logical line, overriding :confval:`python_maximum_signature_line_length`
384
- and :confval:`maximum_signature_line_length`.
383
+ Ensure that the class type parameters are emitted on a single logical
384
+ line, overriding :confval:`python_maximum_signature_line_length` and
385
+ :confval:`maximum_signature_line_length`.
385
386
386
387
.. rst :directive :: .. py:attribute:: name
387
388
@@ -620,7 +621,19 @@ argument support), you can use brackets to specify the optional parts:
620
621
It is customary to put the opening bracket before the comma.
621
622
622
623
Since Python 3.12, it is possible to indicate type parameters directly at the
623
- function or class definition site::
624
+ function or class definition site:
625
+
626
+ .. code-block :: python
627
+
628
+ class MyDict[T](dict[str , T]):
629
+ ...
630
+
631
+ def add[T](x: T, y: T) -> T:
632
+ return x + y
633
+
634
+ The corresponding documentation would look like::
635
+
636
+ .. py:class:: MyDict[T]
624
637
625
638
.. py:function:: add[T](x: T, y: T) -> T
626
639
0 commit comments