Skip to content

Commit a1c77f1

Browse files
authored
Improve wording for the :type:directive option warning (sphinx-doc#13256)
1 parent 42f300e commit a1c77f1

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

doc/usage/domains/python.rst

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,15 @@ The following directives are provided for module and class contents:
135135
136136
This will be parsed as a Python expression for cross-referencing
137137
the type annotation.
138-
As such, the argument to ``:type:`` should be a valid Python expression.
138+
As such, the argument to ``:type:`` should be a valid `annotation expression`_.
139139
140-
.. caution:: The valid syntax for the ``:type:`` directive option
141-
differs from the syntax for the ``:type:`` `info field
142-
<info-field-lists_>`__.
140+
.. caution::
141+
The valid syntax for the ``:type:`` directive option differs from
142+
the syntax for the ``:type:`` `info field <info-field-lists_>`__.
143+
The ``:type:`` directive option does not understand
144+
reStructuredText markup or the ``or`` or ``of`` keywords,
145+
meaning unions must use ``|`` and sequences must use square brackets,
146+
and roles such as ``:ref:`...``` cannot be used.
143147
144148
.. versionadded:: 2.4
145149
@@ -277,11 +281,15 @@ The following directives are provided for module and class contents:
277281
278282
This will be parsed as a Python expression for cross-referencing
279283
the type annotation.
280-
As such, the argument to ``:type:`` should be a valid Python expression.
284+
As such, the argument to ``:type:`` should be a valid `annotation expression`_.
281285
282-
.. caution:: The valid syntax for the ``:type:`` directive option
283-
differs from the syntax for the ``:type:`` `info field
284-
<info-field-lists_>`__.
286+
.. caution::
287+
The valid syntax for the ``:type:`` directive option differs from
288+
the syntax for the ``:type:`` `info field <info-field-lists_>`__.
289+
The ``:type:`` directive option does not understand
290+
reStructuredText markup or the ``or`` or ``of`` keywords,
291+
meaning unions must use ``|`` and sequences must use square brackets,
292+
and roles such as ``:ref:`...``` cannot be used.
285293
286294
.. versionadded:: 2.4
287295
@@ -329,11 +337,15 @@ The following directives are provided for module and class contents:
329337
330338
This will be parsed as a Python expression for cross-referencing
331339
the type annotation.
332-
As such, the argument to ``:type:`` should be a valid Python expression.
340+
As such, the argument to ``:type:`` should be a valid `annotation expression`_.
333341
334-
.. caution:: The valid syntax for the ``:type:`` directive option
335-
differs from the syntax for the ``:type:`` `info field
336-
<info-field-lists_>`__.
342+
.. caution::
343+
The valid syntax for the ``:type:`` directive option differs from
344+
the syntax for the ``:type:`` `info field <info-field-lists_>`__.
345+
The ``:type:`` directive option does not understand
346+
reStructuredText markup or the ``or`` or ``of`` keywords,
347+
meaning unions must use ``|`` and sequences must use square brackets,
348+
and roles such as ``:ref:`...``` cannot be used.
337349
338350
.. rst::directive:option:: module
339351
:type: text
@@ -542,6 +554,8 @@ The following directives are provided for module and class contents:
542554

543555
Refer to a decorator method using the :rst:role:`py:meth` role.
544556

557+
.. _annotation expression: https://typing.readthedocs.io/en/latest/spec/annotations.html#type-and-annotation-expressions
558+
545559
.. _signatures:
546560

547561
Python Signatures

0 commit comments

Comments
 (0)