From ec4ccb07cca10b7cfc15e126312fbbaa32a548ec Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 7 Dec 2024 11:44:05 +0100 Subject: [PATCH] Add sphinx_inline_tabs to docs (#18262) https://sphinx-inline-tabs.readthedocs.io/en/latest/ --- docs/requirements-docs.txt | 1 + docs/source/conf.py | 7 +++- docs/source/running_mypy.rst | 64 +++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index a94c1b7ba95c..747f376a8f5a 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,3 +1,4 @@ sphinx>=8.1.0 furo>=2022.3.4 myst-parser>=4.0.0 +sphinx_inline_tabs>=2023.04.21 diff --git a/docs/source/conf.py b/docs/source/conf.py index ddc9923c6c93..79a5c0619615 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -35,7 +35,12 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.intersphinx", "docs.source.html_builder", "myst_parser"] +extensions = [ + "sphinx.ext.intersphinx", + "sphinx_inline_tabs", + "docs.source.html_builder", + "myst_parser", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/docs/source/running_mypy.rst b/docs/source/running_mypy.rst index ff042b395e99..9f7461d24f72 100644 --- a/docs/source/running_mypy.rst +++ b/docs/source/running_mypy.rst @@ -285,16 +285,22 @@ If you are getting this error, try to obtain type hints for the library you're u You can do this via setting the :option:`--follow-untyped-imports ` command line flag or :confval:`follow_untyped_imports` config file option to True. - This option can be specified on a per-module basis as well:: + This option can be specified on a per-module basis as well: - # mypy.ini - [mypy-untyped_package.*] - follow_untyped_imports = True + .. tab:: mypy.ini - # pyproject.toml - [[tool.mypy.overrides]] - module = ["untyped_package.*"] - follow_untyped_imports = true + .. code-block:: ini + + [mypy-untyped_package.*] + follow_untyped_imports = True + + .. tab:: pyproject.toml + + .. code-block:: toml + + [[tool.mypy.overrides]] + module = ["untyped_package.*"] + follow_untyped_imports = true If you are unable to find any existing type hints nor have time to write your own, you can instead *suppress* the errors. @@ -312,16 +318,22 @@ not catch errors in its use. suppose your codebase makes heavy use of an (untyped) library named ``foobar``. You can silence all import errors associated with that library and that library alone by - adding the following section to your config file:: + adding the following section to your config file: + + .. tab:: mypy.ini + + .. code-block:: ini - # mypy.ini - [mypy-foobar.*] - ignore_missing_imports = True + [mypy-foobar.*] + ignore_missing_imports = True - # pyproject.toml - [[tool.mypy.overrides]] - module = ["foobar.*"] - ignore_missing_imports = true + .. tab:: pyproject.toml + + .. code-block:: toml + + [[tool.mypy.overrides]] + module = ["foobar.*"] + ignore_missing_imports = true Note: this option is equivalent to adding a ``# type: ignore`` to every import of ``foobar`` in your codebase. For more information, see the @@ -334,15 +346,21 @@ not catch errors in its use. in your codebase, use :option:`--disable-error-code=import-untyped `. See :ref:`code-import-untyped` for more details on this error code. - You can also set :confval:`disable_error_code`, like so:: + You can also set :confval:`disable_error_code`, like so: + + .. tab:: mypy.ini + + .. code-block:: ini + + [mypy] + disable_error_code = import-untyped + + .. tab:: pyproject.toml - # mypy.ini - [mypy] - disable_error_code = import-untyped + .. code-block:: ini - # pyproject.toml - [tool.mypy] - disable_error_code = ["import-untyped"] + [tool.mypy] + disable_error_code = ["import-untyped"] You can also set the :option:`--ignore-missing-imports ` command line flag or set the :confval:`ignore_missing_imports` config file