Skip to content

Commit 01cfcc9

Browse files
Fix typos and introduce codespell pre-commit hook (#12769) (#12774)
(cherry picked from commit 09e386e) Co-authored-by: Christian Clauss <[email protected]>
1 parent 4873394 commit 01cfcc9

16 files changed

+32
-18
lines changed

.pre-commit-config.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ repos:
1616
hooks:
1717
- id: blacken-docs
1818
additional_dependencies: [black==24.1.1]
19+
- repo: https://github.com/codespell-project/codespell
20+
rev: v2.3.0
21+
hooks:
22+
- id: codespell
23+
args: ["--toml=pyproject.toml"]
24+
additional_dependencies:
25+
- tomli
1926
- repo: https://github.com/pre-commit/pygrep-hooks
2027
rev: v1.10.0
2128
hooks:

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Chris NeJame
8585
Chris Rose
8686
Chris Wheeler
8787
Christian Boelsen
88+
Christian Clauss
8889
Christian Fetzer
8990
Christian Neumüller
9091
Christian Theunert

CONTRIBUTING.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,4 +543,4 @@ Closing issues
543543

544544
When a pull request is submitted to fix an issue, add text like ``closes #XYZW`` to the PR description and/or commits (where ``XYZW`` is the issue number). See the `GitHub docs <https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>`_ for more information.
545545

546-
When an issue is due to user error (e.g. misunderstanding of a functionality), please politely explain to the user why the issue raised is really a non-issue and ask them to close the issue if they have no further questions. If the original requestor is unresponsive, the issue will be handled as described in the section `Handling stale issues/PRs`_ above.
546+
When an issue is due to user error (e.g. misunderstanding of a functionality), please politely explain to the user why the issue raised is really a non-issue and ask them to close the issue if they have no further questions. If the original requester is unresponsive, the issue will be handled as described in the section `Handling stale issues/PRs`_ above.

changelog/12769.misc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix typos discovered by codespell and add codespell to pre-commit hooks.

doc/en/announce/release-2.3.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ and parametrized testing in Python. It is now easier, more efficient and
66
more predictable to re-run the same tests with different fixture
77
instances. Also, you can directly declare the caching "scope" of
88
fixtures so that dependent tests throughout your whole test suite can
9-
re-use database or other expensive fixture objects with ease. Lastly,
9+
reuse database or other expensive fixture objects with ease. Lastly,
1010
it's possible for fixture functions (formerly known as funcarg
1111
factories) to use other fixtures, allowing for a completely modular and
12-
re-usable fixture design.
12+
reusable fixture design.
1313

1414
For detailed info and tutorial-style examples, see:
1515

doc/en/changelog.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Improved documentation
215215
-- by :user:`webknjaz`
216216

217217

218-
- `#12577 <https://github.com/pytest-dev/pytest/issues/12577>`_: `CI` and `BUILD_NUMBER` environment variables role is discribed in
218+
- `#12577 <https://github.com/pytest-dev/pytest/issues/12577>`_: `CI` and `BUILD_NUMBER` environment variables role is described in
219219
the reference doc. They now also appear when doing `pytest -h`
220220
-- by :user:`MarcBresson`.
221221

@@ -319,7 +319,7 @@ Bug Fixes
319319
- `#12367 <https://github.com/pytest-dev/pytest/issues/12367>`_: Fix a regression in pytest 8.2.0 where unittest class instances (a fresh one is created for each test) were not released promptly on test teardown but only on session teardown.
320320

321321

322-
- `#12381 <https://github.com/pytest-dev/pytest/issues/12381>`_: Fix possible "Directory not empty" crashes arising from concurent cache dir (``.pytest_cache``) creation. Regressed in pytest 8.2.0.
322+
- `#12381 <https://github.com/pytest-dev/pytest/issues/12381>`_: Fix possible "Directory not empty" crashes arising from concurrent cache dir (``.pytest_cache``) creation. Regressed in pytest 8.2.0.
323323

324324

325325

@@ -330,7 +330,7 @@ Improved Documentation
330330

331331

332332
- `#12356 <https://github.com/pytest-dev/pytest/issues/12356>`_: Added a subsection to the documentation for debugging flaky tests to mention
333-
lack of thread safety in pytest as a possible source of flakyness.
333+
lack of thread safety in pytest as a possible source of flakiness.
334334

335335

336336
- `#12363 <https://github.com/pytest-dev/pytest/issues/12363>`_: The documentation webpages now links to a canonical version to reduce outdated documentation in search engine results.
@@ -676,7 +676,7 @@ Bug Fixes
676676
This bug was introduced in pytest 8.0.0rc1.
677677

678678

679-
- `#9765 <https://github.com/pytest-dev/pytest/issues/9765>`_, `#11816 <https://github.com/pytest-dev/pytest/issues/11816>`_: Fixed a frustrating bug that afflicted some users with the only error being ``assert mod not in mods``. The issue was caused by the fact that ``str(Path(mod))`` and ``mod.__file__`` don't necessarily produce the same string, and was being erroneously used interchangably in some places in the code.
679+
- `#9765 <https://github.com/pytest-dev/pytest/issues/9765>`_, `#11816 <https://github.com/pytest-dev/pytest/issues/11816>`_: Fixed a frustrating bug that afflicted some users with the only error being ``assert mod not in mods``. The issue was caused by the fact that ``str(Path(mod))`` and ``mod.__file__`` don't necessarily produce the same string, and was being erroneously used interchangeably in some places in the code.
680680

681681
This fix also broke the internal API of ``PytestPluginManager.consider_conftest`` by introducing a new parameter -- we mention this in case it is being used by external code, even if marked as *private*.
682682

doc/en/deprecations.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ If the import attempt raises :class:`ModuleNotFoundError` (the usual case), then
4343
warning is emitted.
4444

4545
This way, the usual cases will keep working the same way, while unexpected errors will now issue a warning, with
46-
users being able to supress the warning by passing ``exc_type=ImportError`` explicitly.
46+
users being able to suppress the warning by passing ``exc_type=ImportError`` explicitly.
4747

4848
In ``9.0``, the warning will turn into an error, and in ``9.1`` :func:`pytest.importorskip` will only capture
4949
:class:`ModuleNotFoundError` by default and no warnings will be issued anymore -- but users can still capture

doc/en/explanation/fixtures.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ style of setup/teardown functions:
7575

7676
* fixture management scales from simple unit to complex
7777
functional testing, allowing to parametrize fixtures and tests according
78-
to configuration and component options, or to re-use fixtures
78+
to configuration and component options, or to reuse fixtures
7979
across function, class, module or whole test session scopes.
8080

8181
* teardown logic can be easily, and safely managed, no matter how many fixtures

doc/en/funcarg_compare.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Shortcomings of the previous ``pytest_funcarg__`` mechanism
1616

1717
The pre pytest-2.3 funcarg mechanism calls a factory each time a
1818
funcarg for a test function is required. If a factory wants to
19-
re-use a resource across different scopes, it often used
19+
reuse a resource across different scopes, it often used
2020
the ``request.cached_setup()`` helper to manage caching of
2121
resources. Here is a basic example how we could implement
2222
a per-session Database object:
@@ -107,7 +107,7 @@ the tests requiring "db" will run twice as well. The "mysql" and
107107
"pg" values will also be used for reporting the test-invocation variants.
108108

109109
This new way of parametrizing funcarg factories should in many cases
110-
allow to re-use already written factories because effectively
110+
allow to reuse already written factories because effectively
111111
``request.param`` was already used when test functions/classes were
112112
parametrized via
113113
:py:func:`metafunc.parametrize(indirect=True) <pytest.Metafunc.parametrize>` calls.
@@ -164,7 +164,7 @@ hook which are often used to setup global resources. This suffers from
164164
several problems:
165165

166166
1. in distributed testing the managing process would setup test resources
167-
that are never needed because it only co-ordinates the test run
167+
that are never needed because it only coordinates the test run
168168
activities of the worker processes.
169169

170170
2. if you only perform a collection (with "--collect-only")

doc/en/how-to/fixtures.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ Modularity: using fixtures from a fixture function
14871487

14881488
In addition to using fixtures in test functions, fixture functions
14891489
can use other fixtures themselves. This contributes to a modular design
1490-
of your fixtures and allows re-use of framework-specific fixtures across
1490+
of your fixtures and allows reuse of framework-specific fixtures across
14911491
many projects. As a simple example, we can extend the previous example
14921492
and instantiate an object ``app`` where we stick the already defined
14931493
``smtp_connection`` resource into it:

doc/en/how-to/unittest.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ achieves this by receiving a special ``request`` object which gives
109109
access to :ref:`the requesting test context <request-context>` such
110110
as the ``cls`` attribute, denoting the class from which the fixture
111111
is used. This architecture de-couples fixture writing from actual test
112-
code and allows re-use of the fixture by a minimal reference, the fixture
112+
code and allows reuse of the fixture by a minimal reference, the fixture
113113
name. So let's write an actual ``unittest.TestCase`` class using our
114114
fixture definition:
115115

pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ disable = [
306306
"wrong-import-position", # handled by isort / ruff
307307
]
308308

309+
[tool.codespell]
310+
ignore-words-list = "afile,asser,assertio,feld,hove,ned,noes,notin,paramete,parth,socio-economic,tesults,varius,wil"
311+
skip = "*/plugin_list.rst"
312+
write-changes = true
313+
309314
[tool.check-wheel-contents]
310315
# check-wheel-contents is executed by the build-and-inspect-python-package action.
311316
# W009: Wheel contains multiple toplevel library entries

src/_pytest/config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def _get_legacy_hook_marks(
361361
opt_names: tuple[str, ...],
362362
) -> dict[str, bool]:
363363
if TYPE_CHECKING:
364-
# abuse typeguard from importlib to avoid massive method type union thats lacking a alias
364+
# abuse typeguard from importlib to avoid massive method type union that's lacking an alias
365365
assert inspect.isroutine(method)
366366
known_marks: set[str] = {m.name for m in getattr(method, "pytestmark", [])}
367367
must_warn: list[str] = []

src/_pytest/debugging.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def maybe_wrap_pytest_function_for_tracing(pyfuncitem) -> None:
332332
def _enter_pdb(
333333
node: Node, excinfo: ExceptionInfo[BaseException], rep: BaseReport
334334
) -> BaseReport:
335-
# XXX we re-use the TerminalReporter's terminalwriter
335+
# XXX we reuse the TerminalReporter's terminalwriter
336336
# because this seems to avoid some encoding related troubles
337337
# for not completely clear reasons.
338338
tw = node.config.pluginmanager.getplugin("terminalreporter")._tw

testing/python/fixtures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4338,7 +4338,7 @@ def test_func(self, f2, f1, m2):
43384338
assert request.fixturenames == "s1 p1 m1 m2 c1 f2 f1".split()
43394339

43404340
def test_parametrized_package_scope_reordering(self, pytester: Pytester) -> None:
4341-
"""A paramaterized package-scoped fixture correctly reorders items to
4341+
"""A parameterized package-scoped fixture correctly reorders items to
43424342
minimize setups & teardowns.
43434343
43444344
Regression test for #12328.

testing/test_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def pytest_addoption(parser):
917917
# default for string is ""
918918
value = config.getini("string1")
919919
assert value == ""
920-
# should return None if None is explicity set as default value
920+
# should return None if None is explicitly set as default value
921921
# irrespective of the type argument
922922
value = config.getini("none_1")
923923
assert value is None

0 commit comments

Comments
 (0)