Skip to content

Commit

Permalink
Add sphinx_inline_tabs to docs (#18262)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Dec 7, 2024
1 parent f7a7ed7 commit ec4ccb0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 24 deletions.
1 change: 1 addition & 0 deletions docs/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx>=8.1.0
furo>=2022.3.4
myst-parser>=4.0.0
sphinx_inline_tabs>=2023.04.21
7 changes: 6 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
64 changes: 41 additions & 23 deletions docs/source/running_mypy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mypy --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.
Expand All @@ -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
Expand All @@ -334,15 +346,21 @@ not catch errors in its use.
in your codebase, use :option:`--disable-error-code=import-untyped <mypy --ignore-missing-imports>`.
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 <mypy --ignore-missing-imports>`
command line flag or set the :confval:`ignore_missing_imports` config file
Expand Down

0 comments on commit ec4ccb0

Please sign in to comment.