Skip to content

Commit fda7a46

Browse files
authored
Fix all the missing references found within the docs (#15875)
Fixes #13196. Enable the nit-picky mode on sphinx-build in tox, as this will facilitate the detection of potential issues related to missing references.
1 parent b49be10 commit fda7a46

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

docs/source/error_code_list.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ ellipsis ``...``, a docstring, and a ``raise NotImplementedError`` statement.
835835
Check the target of NewType [valid-newtype]
836836
-------------------------------------------
837837

838-
The target of a :py:func:`NewType <typing.NewType>` definition must be a class type. It can't
838+
The target of a :py:class:`~typing.NewType` definition must be a class type. It can't
839839
be a union type, ``Any``, or various other special types.
840840

841841
You can also get this error if the target has been imported from a

docs/source/more_types.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ More types
22
==========
33

44
This section introduces a few additional kinds of types, including :py:data:`~typing.NoReturn`,
5-
:py:func:`NewType <typing.NewType>`, and types for async code. It also discusses
5+
:py:class:`~typing.NewType`, and types for async code. It also discusses
66
how to give functions more precise types using overloads. All of these are only
77
situationally useful, so feel free to skip this section and come back when you
88
have a need for some of them.
@@ -11,7 +11,7 @@ Here's a quick summary of what's covered here:
1111

1212
* :py:data:`~typing.NoReturn` lets you tell mypy that a function never returns normally.
1313

14-
* :py:func:`NewType <typing.NewType>` lets you define a variant of a type that is treated as a
14+
* :py:class:`~typing.NewType` lets you define a variant of a type that is treated as a
1515
separate type by mypy but is identical to the original type at runtime.
1616
For example, you can have ``UserId`` as a variant of ``int`` that is
1717
just an ``int`` at runtime.
@@ -75,7 +75,7 @@ certain values from base class instances. Example:
7575
...
7676
7777
However, this approach introduces some runtime overhead. To avoid this, the typing
78-
module provides a helper object :py:func:`NewType <typing.NewType>` that creates simple unique types with
78+
module provides a helper object :py:class:`~typing.NewType` that creates simple unique types with
7979
almost zero runtime overhead. Mypy will treat the statement
8080
``Derived = NewType('Derived', Base)`` as being roughly equivalent to the following
8181
definition:
@@ -113,12 +113,12 @@ implicitly casting from ``UserId`` where ``int`` is expected. Examples:
113113
114114
num: int = UserId(5) + 1
115115
116-
:py:func:`NewType <typing.NewType>` accepts exactly two arguments. The first argument must be a string literal
116+
:py:class:`~typing.NewType` accepts exactly two arguments. The first argument must be a string literal
117117
containing the name of the new type and must equal the name of the variable to which the new
118118
type is assigned. The second argument must be a properly subclassable class, i.e.,
119119
not a type construct like :py:data:`~typing.Union`, etc.
120120

121-
The callable returned by :py:func:`NewType <typing.NewType>` accepts only one argument; this is equivalent to
121+
The callable returned by :py:class:`~typing.NewType` accepts only one argument; this is equivalent to
122122
supporting only one constructor accepting an instance of the base class (see above).
123123
Example:
124124

@@ -139,12 +139,12 @@ Example:
139139
tcp_packet = TcpPacketId(127, 0) # Fails in type checker and at runtime
140140
141141
You cannot use :py:func:`isinstance` or :py:func:`issubclass` on the object returned by
142-
:py:func:`~typing.NewType`, nor can you subclass an object returned by :py:func:`~typing.NewType`.
142+
:py:class:`~typing.NewType`, nor can you subclass an object returned by :py:class:`~typing.NewType`.
143143

144144
.. note::
145145

146-
Unlike type aliases, :py:func:`NewType <typing.NewType>` will create an entirely new and
147-
unique type when used. The intended purpose of :py:func:`NewType <typing.NewType>` is to help you
146+
Unlike type aliases, :py:class:`~typing.NewType` will create an entirely new and
147+
unique type when used. The intended purpose of :py:class:`~typing.NewType` is to help you
148148
detect cases where you accidentally mixed together the old base type and the
149149
new derived type.
150150

@@ -160,7 +160,7 @@ You cannot use :py:func:`isinstance` or :py:func:`issubclass` on the object retu
160160
161161
name_by_id(3) # ints and UserId are synonymous
162162
163-
But a similar example using :py:func:`NewType <typing.NewType>` will not typecheck:
163+
But a similar example using :py:class:`~typing.NewType` will not typecheck:
164164

165165
.. code-block:: python
166166

docs/source/runtime_troubles.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ required to be valid Python syntax. For more details, see :pep:`563`.
8686

8787
* :ref:`type aliases <type-aliases>`;
8888
* :ref:`type narrowing <type-narrowing>`;
89-
* type definitions (see :py:class:`~typing.TypeVar`, :py:func:`~typing.NewType`, :py:class:`~typing.NamedTuple`);
89+
* type definitions (see :py:class:`~typing.TypeVar`, :py:class:`~typing.NewType`, :py:class:`~typing.NamedTuple`);
9090
* base classes.
9191

9292
.. code-block:: python
@@ -263,7 +263,7 @@ If your subclass is also generic, you can use the following:
263263
reveal_type(task_queue.get()) # Reveals str
264264
265265
In Python 3.9, we can just inherit directly from ``Queue[str]`` or ``Queue[T]``
266-
since its :py:class:`queue.Queue` implements :py:meth:`__class_getitem__`, so
266+
since its :py:class:`queue.Queue` implements :py:meth:`~object.__class_getitem__`, so
267267
the class object can be subscripted at runtime without issue.
268268

269269
Using types defined in stubs but not at runtime

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ passenv =
3737
VERIFY_MYPY_ERROR_CODES
3838
deps = -rdocs/requirements-docs.txt
3939
commands =
40-
sphinx-build -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
40+
sphinx-build -n -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
4141
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'
4242

4343
[testenv:lint]

0 commit comments

Comments
 (0)