Skip to content

Commit

Permalink
Support Sphinx 7.x (#16460)
Browse files Browse the repository at this point in the history
This is needed for the Debian package of mypy, as we package the docs
and we have upgraded to Sphinx 7.2.6 from 5.3.0 for the next release.
Thanks!

Bonus: Adjust many links to docs.python.org so that intersphinx can
connect them to local file for offline use.
  • Loading branch information
mr-c committed Nov 11, 2023
1 parent c68bd7a commit a7c53d3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/requirements-docs.txt
@@ -1,2 +1,2 @@
sphinx>=4.2.0,<5.0.0
sphinx>=5.1.0
furo>=2022.3.4
5 changes: 2 additions & 3 deletions docs/source/class_basics.rst
Expand Up @@ -263,7 +263,7 @@ effect at runtime:
Abstract base classes and multiple inheritance
**********************************************

Mypy supports Python :doc:`abstract base classes <library/abc>` (ABCs). Abstract classes
Mypy supports Python :doc:`abstract base classes <python:library/abc>` (ABCs). Abstract classes
have at least one abstract method or property that must be implemented
by any *concrete* (non-abstract) subclass. You can define abstract base
classes using the :py:class:`abc.ABCMeta` metaclass and the :py:func:`@abc.abstractmethod <abc.abstractmethod>`
Expand Down Expand Up @@ -371,8 +371,7 @@ property or an instance variable.
Slots
*****

When a class has explicitly defined
`__slots__ <https://docs.python.org/3/reference/datamodel.html#slots>`_,
When a class has explicitly defined :std:term:`__slots__`,
mypy will check that all attributes assigned to are members of ``__slots__``:

.. code-block:: python
Expand Down
6 changes: 2 additions & 4 deletions docs/source/config_file.rst
Expand Up @@ -238,10 +238,8 @@ section of the command line docs.
Crafting a single regular expression that excludes multiple files while remaining
human-readable can be a challenge. The above example demonstrates one approach.
``(?x)`` enables the ``VERBOSE`` flag for the subsequent regular expression, which
`ignores most whitespace and supports comments`__. The above is equivalent to:
``(^one\.py$|two\.pyi$|^three\.)``.

.. __: https://docs.python.org/3/library/re.html#re.X
:py:data:`ignores most whitespace and supports comments <re.VERBOSE>`.
The above is equivalent to: ``(^one\.py$|two\.pyi$|^three\.)``.

For more details, see :option:`--exclude <mypy --exclude>`.

Expand Down
3 changes: 1 addition & 2 deletions docs/source/error_code_list2.rst
Expand Up @@ -524,8 +524,7 @@ that only existed during type-checking.
In runtime it fails with expected ``NameError``,
which can cause real problem in production, hidden from mypy.

But, in Python3.11 ``reveal_type``
`was added to typing.py <https://docs.python.org/3/library/typing.html#typing.reveal_type>`_.
But, in Python3.11 :py:func:`typing.reveal_type` was added.
``typing_extensions`` ported this helper to all supported Python versions.

Now users can actually import ``reveal_type`` to make the runtime code safe.
Expand Down
3 changes: 1 addition & 2 deletions docs/source/getting_started.rst
Expand Up @@ -256,8 +256,7 @@ Mypy can also understand how to work with types from libraries that you use.

For instance, mypy comes out of the box with an intimate knowledge of the
Python standard library. For example, here is a function which uses the
``Path`` object from the
`pathlib standard library module <https://docs.python.org/3/library/pathlib.html>`_:
``Path`` object from the :doc:`pathlib standard library module <python:library/pathlib>`:

.. code-block:: python
Expand Down
5 changes: 3 additions & 2 deletions docs/source/html_builder.py
Expand Up @@ -9,11 +9,12 @@
from sphinx.addnodes import document
from sphinx.application import Sphinx
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.environment import BuildEnvironment


class MypyHTMLBuilder(StandaloneHTMLBuilder):
def __init__(self, app: Sphinx) -> None:
super().__init__(app)
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
super().__init__(app, env)
self._ref_to_doc = {}

def write_doc(self, docname: str, doctree: document) -> None:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/more_types.rst
Expand Up @@ -829,7 +829,7 @@ Typing async/await

Mypy lets you type coroutines that use the ``async/await`` syntax.
For more information regarding coroutines, see :pep:`492` and the
`asyncio documentation <https://docs.python.org/3/library/asyncio.html>`_.
`asyncio documentation <python:library/asyncio>`_.

Functions defined using ``async def`` are typed similar to normal functions.
The return type annotation should be the same as the type of the value you
Expand Down

0 comments on commit a7c53d3

Please sign in to comment.