Skip to content

Commit c133962

Browse files
authored
Merge pull request #11684 from bluetech/docs-nitpicky
docs: enable Sphinx nitpicky mode
2 parents 397769c + 2aa8743 commit c133962

File tree

9 files changed

+71
-30
lines changed

9 files changed

+71
-30
lines changed

doc/en/changelog.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ Features
13441344

13451345
This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
13461346

1347-
Internally, the old :class:`~pytest.Testdir` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
1347+
Internally, the old ``pytest.Testdir`` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
13481348

13491349

13501350
- :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
@@ -1592,7 +1592,7 @@ Improvements
15921592

15931593

15941594
- :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`.
1595-
These attributes are :class:`pathlib.Path` versions of the existing :attr:`rootdir <pytest.Config.rootdir>` and :attr:`inifile <pytest.Config.inifile>` attributes,
1595+
These attributes are :class:`pathlib.Path` versions of the existing ``rootdir`` and ``inifile`` attributes,
15961596
and should be preferred over them when possible.
15971597

15981598

@@ -2139,7 +2139,7 @@ Bug Fixes
21392139
parameter when Python is called with the ``-bb`` flag.
21402140

21412141

2142-
- :issue:`7143`: Fix :meth:`pytest.File.from_parent` so it forwards extra keyword arguments to the constructor.
2142+
- :issue:`7143`: Fix :meth:`pytest.File.from_parent <_pytest.nodes.Node.from_parent>` so it forwards extra keyword arguments to the constructor.
21432143

21442144

21452145
- :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
@@ -2458,7 +2458,7 @@ Bug Fixes
24582458
- :issue:`6597`: Fix node ids which contain a parametrized empty-string variable.
24592459

24602460

2461-
- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's :func:`testdir.runpytest <pytest.Testdir.runpytest>` etc.
2461+
- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's ``testdir.runpytest`` etc.
24622462

24632463

24642464
- :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger.

doc/en/conf.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,50 @@
169169
}
170170

171171

172+
nitpicky = True
173+
nitpick_ignore = [
174+
# TODO (fix in pluggy?)
175+
("py:class", "HookCaller"),
176+
("py:class", "HookspecMarker"),
177+
("py:exc", "PluginValidationError"),
178+
# Might want to expose/TODO (https://github.com/pytest-dev/pytest/issues/7469)
179+
("py:class", "ExceptionRepr"),
180+
("py:class", "Exit"),
181+
("py:class", "SubRequest"),
182+
("py:class", "SubRequest"),
183+
("py:class", "TerminalReporter"),
184+
("py:class", "_pytest._code.code.TerminalRepr"),
185+
("py:class", "_pytest.fixtures.FixtureFunctionMarker"),
186+
("py:class", "_pytest.logging.LogCaptureHandler"),
187+
("py:class", "_pytest.mark.structures.ParameterSet"),
188+
# Intentionally undocumented/private
189+
("py:class", "_pytest._code.code.Traceback"),
190+
("py:class", "_pytest._py.path.LocalPath"),
191+
("py:class", "_pytest.capture.CaptureResult"),
192+
("py:class", "_pytest.compat.NotSetType"),
193+
("py:class", "_pytest.python.PyCollector"),
194+
("py:class", "_pytest.python.PyobjMixin"),
195+
("py:class", "_pytest.python_api.RaisesContext"),
196+
("py:class", "_pytest.recwarn.WarningsChecker"),
197+
("py:class", "_pytest.reports.BaseReport"),
198+
# Undocumented third parties
199+
("py:class", "_tracing.TagTracerSub"),
200+
("py:class", "warnings.WarningMessage"),
201+
# Undocumented type aliases
202+
("py:class", "LEGACY_PATH"),
203+
("py:class", "_PluggyPlugin"),
204+
# TypeVars
205+
("py:class", "_pytest._code.code.E"),
206+
("py:class", "_pytest.fixtures.FixtureFunction"),
207+
("py:class", "_pytest.nodes._NodeType"),
208+
("py:class", "_pytest.python_api.E"),
209+
("py:class", "_pytest.recwarn.T"),
210+
("py:class", "_pytest.runner.TResult"),
211+
("py:obj", "_pytest.fixtures.FixtureValue"),
212+
("py:obj", "_pytest.stash.T"),
213+
]
214+
215+
172216
# -- Options for HTML output ---------------------------------------------------
173217

174218
sys.path.append(os.path.abspath("_themes"))

doc/en/example/simple.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Now we'll get feedback on a bad argument:
168168
169169
170170
If you need to provide more detailed error messages, you can use the
171-
``type`` parameter and raise ``pytest.UsageError``:
171+
``type`` parameter and raise :exc:`pytest.UsageError`:
172172

173173
.. code-block:: python
174174

doc/en/funcarg_compare.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ There are several limitations and difficulties with this approach:
4444

4545
2. parametrizing the "db" resource is not straight forward:
4646
you need to apply a "parametrize" decorator or implement a
47-
:py:func:`~hookspec.pytest_generate_tests` hook
47+
:hook:`pytest_generate_tests` hook
4848
calling :py:func:`~pytest.Metafunc.parametrize` which
4949
performs parametrization at the places where the resource
5050
is used. Moreover, you need to modify the factory to use an
@@ -92,7 +92,7 @@ Direct parametrization of funcarg resource factories
9292

9393
Previously, funcarg factories could not directly cause parametrization.
9494
You needed to specify a ``@parametrize`` decorator on your test function
95-
or implement a ``pytest_generate_tests`` hook to perform
95+
or implement a :hook:`pytest_generate_tests` hook to perform
9696
parametrization, i.e. calling a test multiple times with different value
9797
sets. pytest-2.3 introduces a decorator for use on the factory itself:
9898

doc/en/reference/reference.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,10 @@ When set (regardless of value), pytest will use color in terminal output.
11581158
Exceptions
11591159
----------
11601160

1161-
.. autoclass:: pytest.UsageError()
1161+
.. autoexception:: pytest.UsageError()
1162+
:show-inheritance:
1163+
1164+
.. autoexception:: pytest.FixtureLookupError()
11621165
:show-inheritance:
11631166

11641167
.. _`warnings ref`:

src/_pytest/config/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ def __init__(self) -> None:
449449
def parse_hookimpl_opts(
450450
self, plugin: _PluggyPlugin, name: str
451451
) -> Optional[HookimplOpts]:
452+
""":meta private:"""
452453
# pytest hooks are always prefixed with "pytest_",
453454
# so we avoid accessing possibly non-readable attributes
454455
# (see issue #1073).
@@ -472,6 +473,7 @@ def parse_hookimpl_opts(
472473
)
473474

474475
def parse_hookspec_opts(self, module_or_class, name: str) -> Optional[HookspecOpts]:
476+
""":meta private:"""
475477
opts = super().parse_hookspec_opts(module_or_class, name)
476478
if opts is None:
477479
method = getattr(module_or_class, name)

src/_pytest/hookspec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
@hookspec(historic=True)
5656
def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
5757
"""Called at plugin registration time to allow adding new hooks via a call to
58-
``pluginmanager.add_hookspecs(module_or_class, prefix)``.
58+
:func:`pluginmanager.add_hookspecs(module_or_class, prefix) <pytest.PytestPluginManager.add_hookspecs>`.
5959
6060
:param pytest.PytestPluginManager pluginmanager: The pytest plugin manager.
6161
@@ -858,8 +858,8 @@ def pytest_warning_recorded(
858858
"""Process a warning captured by the internal pytest warnings plugin.
859859
860860
:param warning_message:
861-
The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
862-
the same attributes as the parameters of :py:func:`warnings.showwarning`.
861+
The captured warning. This is the same object produced by :class:`warnings.catch_warnings`,
862+
and contains the same attributes as the parameters of :py:func:`warnings.showwarning`.
863863
864864
:param when:
865865
Indicates when the warning was captured. Possible values:
@@ -940,10 +940,10 @@ def pytest_exception_interact(
940940
interactively handled.
941941
942942
May be called during collection (see :hook:`pytest_make_collect_report`),
943-
in which case ``report`` is a :class:`CollectReport`.
943+
in which case ``report`` is a :class:`~pytest.CollectReport`.
944944
945945
May be called during runtest of an item (see :hook:`pytest_runtest_protocol`),
946-
in which case ``report`` is a :class:`TestReport`.
946+
in which case ``report`` is a :class:`~pytest.TestReport`.
947947
948948
This hook is not called if the exception that was raised is an internal
949949
exception like ``skip.Exception``.

src/_pytest/nodes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import abc
22
import os
3+
import pathlib
34
import warnings
45
from functools import cached_property
56
from inspect import signature
@@ -177,8 +178,8 @@ class Node(abc.ABC, metaclass=NodeMeta):
177178
# Implemented in the legacypath plugin.
178179
#: A ``LEGACY_PATH`` copy of the :attr:`path` attribute. Intended for usage
179180
#: for methods not migrated to ``pathlib.Path`` yet, such as
180-
#: :meth:`Item.reportinfo`. Will be deprecated in a future release, prefer
181-
#: using :attr:`path` instead.
181+
#: :meth:`Item.reportinfo <pytest.Item.reportinfo>`. Will be deprecated in
182+
#: a future release, prefer using :attr:`path` instead.
182183
fspath: LEGACY_PATH
183184

184185
# Use __slots__ to make attribute access faster.
@@ -229,7 +230,7 @@ def __init__(
229230
if path is None and fspath is None:
230231
path = getattr(parent, "path", None)
231232
#: Filesystem path where this node was collected from (can be None).
232-
self.path: Path = _imply_path(type(self), path, fspath=fspath)
233+
self.path: pathlib.Path = _imply_path(type(self), path, fspath=fspath)
233234

234235
# The explicit annotation is to avoid publicly exposing NodeKeywords.
235236
#: Keywords/markers collected from all scopes.

src/_pytest/python_api.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@
3030
from numpy import ndarray
3131

3232

33-
def _non_numeric_type_error(value, at: Optional[str]) -> TypeError:
34-
at_str = f" at {at}" if at else ""
35-
return TypeError(
36-
"cannot make approximate comparisons to non-numeric values: {!r} {}".format(
37-
value, at_str
38-
)
39-
)
40-
41-
4233
def _compare_approx(
4334
full_object: object,
4435
message_data: Sequence[Tuple[str, str, str]],
@@ -806,23 +797,23 @@ def raises( # noqa: F811
806797
) -> Union["RaisesContext[E]", _pytest._code.ExceptionInfo[E]]:
807798
r"""Assert that a code block/function call raises an exception type, or one of its subclasses.
808799
809-
:param typing.Type[E] | typing.Tuple[typing.Type[E], ...] expected_exception:
800+
:param expected_exception:
810801
The expected exception type, or a tuple if one of multiple possible
811802
exception types are expected. Note that subclasses of the passed exceptions
812803
will also match.
813804
814-
:kwparam str | typing.Pattern[str] | None match:
805+
:kwparam str | re.Pattern[str] | None match:
815806
If specified, a string containing a regular expression,
816807
or a regular expression object, that is tested against the string
817-
representation of the exception and its `PEP-678 <https://peps.python.org/pep-0678/>` `__notes__`
808+
representation of the exception and its :pep:`678` `__notes__`
818809
using :func:`re.search`.
819810
820811
To match a literal string that may contain :ref:`special characters
821812
<re-syntax>`, the pattern can first be escaped with :func:`re.escape`.
822813
823-
(This is only used when :py:func:`pytest.raises` is used as a context manager,
814+
(This is only used when ``pytest.raises`` is used as a context manager,
824815
and passed through to the function otherwise.
825-
When using :py:func:`pytest.raises` as a function, you can use:
816+
When using ``pytest.raises`` as a function, you can use:
826817
``pytest.raises(Exc, func, match="passed on").match("my pattern")``.)
827818
828819
Use ``pytest.raises`` as a context manager, which will capture the exception of the given

0 commit comments

Comments
 (0)