Skip to content

Commit 68cc1c0

Browse files
committed
Merge branch 'main' into soft-sphinx
2 parents da65208 + 8fa7fa2 commit 68cc1c0

File tree

8 files changed

+68
-63
lines changed

8 files changed

+68
-63
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
name: Run CircleCI artifacts redirector
66
steps:
77
- name: GitHub Action step
8-
uses: scientific-python/circleci-artifacts-redirector-action@839631420e45a08af893032e5a5e8843bf47e8ff # v1.2.0
8+
uses: scientific-python/circleci-artifacts-redirector-action@5d358ff96e96429a5c64a969bb4a574555439f4f # v1.3.1
99
with:
1010
repo-token: ${{ secrets.GITHUB_TOKEN }}
1111
api-token: ${{ secrets.CIRCLECI_ARTIFACT_REDIRECTOR_TOKEN }}

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1616
with:
1717
fetch-depth: 0
18-
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
18+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
1919
with:
2020
python-version: "3.12"
2121
- name: Build wheels
@@ -24,7 +24,7 @@ jobs:
2424
pip install -U build twine wheel
2525
python -m build --sdist --wheel
2626
- run: twine check --strict dist/*
27-
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
27+
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
2828
with:
2929
name: dist
3030
path: dist
@@ -40,8 +40,8 @@ jobs:
4040
# IMPORTANT: this permission is mandatory for trusted publishing
4141
id-token: write
4242
steps:
43-
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
43+
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
4444
with:
4545
name: dist
4646
path: dist
47-
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
47+
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- uses: actions/checkout@v5
3131

3232
- name: Python setup
33-
uses: actions/setup-python@v5
33+
uses: actions/setup-python@v6
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636

@@ -83,7 +83,7 @@ jobs:
8383
- uses: actions/checkout@v5
8484

8585
- name: Python setup
86-
uses: actions/setup-python@v5
86+
uses: actions/setup-python@v6
8787
with:
8888
python-version: ${{ matrix.python-version }}
8989

numpydoc/docscrape_sphinx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def load_config(self, config):
3737
self.template = template_env.get_template("numpydoc_docstring.rst")
3838

3939
# string conversion routines
40-
def _str_header(self, name, symbol="`"):
40+
def _str_header(self, name):
4141
return [".. rubric:: " + name, ""]
4242

4343
def _str_field_list(self, name):

numpydoc/tests/hooks/test_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ def test_find_project_root(tmp_path, request, reason_file, files, expected_reaso
2323
(tmp_path / reason_file).touch()
2424

2525
if files:
26-
expected_dir = Path("/") if expected_reason == "file system root" else tmp_path
26+
expected_dir = (
27+
Path(tmp_path.anchor) if expected_reason == "file system root" else tmp_path
28+
)
29+
2730
for file in files:
2831
(tmp_path / file).touch()
2932
else:

numpydoc/tests/hooks/test_validate_hook.py

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test the numpydoc validate pre-commit hook."""
22

33
import inspect
4+
import re
45
from pathlib import Path
56

67
import pytest
@@ -25,42 +26,42 @@ def test_validate_hook(example_module, config, capsys):
2526
"""Test that a file is correctly processed in the absence of config files."""
2627

2728
expected = inspect.cleandoc(
28-
"""
29-
numpydoc/tests/hooks/example_module.py:4: ES01 No extended summary found
29+
f"""
30+
{example_module!s}:4: ES01 No extended summary found
3031
31-
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
32+
{example_module!s}:4: PR01 Parameters {{'name'}} not documented
3233
33-
numpydoc/tests/hooks/example_module.py:4: SA01 See Also section not found
34+
{example_module!s}:4: SA01 See Also section not found
3435
35-
numpydoc/tests/hooks/example_module.py:4: EX01 No examples section found
36+
{example_module!s}:4: EX01 No examples section found
3637
37-
numpydoc/tests/hooks/example_module.py:8: ES01 No extended summary found
38+
{example_module!s}:8: ES01 No extended summary found
3839
39-
numpydoc/tests/hooks/example_module.py:8: SA01 See Also section not found
40+
{example_module!s}:8: SA01 See Also section not found
4041
41-
numpydoc/tests/hooks/example_module.py:8: EX01 No examples section found
42+
{example_module!s}:8: EX01 No examples section found
4243
43-
numpydoc/tests/hooks/example_module.py:11: GL08 The object does not have a docstring
44+
{example_module!s}:11: GL08 The object does not have a docstring
4445
45-
numpydoc/tests/hooks/example_module.py:17: ES01 No extended summary found
46+
{example_module!s}:17: ES01 No extended summary found
4647
47-
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
48+
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented
4849
49-
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
50+
{example_module!s}:17: PR07 Parameter "*args" has no description
5051
51-
numpydoc/tests/hooks/example_module.py:17: SA01 See Also section not found
52+
{example_module!s}:17: SA01 See Also section not found
5253
53-
numpydoc/tests/hooks/example_module.py:17: EX01 No examples section found
54+
{example_module!s}:17: EX01 No examples section found
5455
55-
numpydoc/tests/hooks/example_module.py:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
56+
{example_module!s}:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
5657
57-
numpydoc/tests/hooks/example_module.py:26: ES01 No extended summary found
58+
{example_module!s}:26: ES01 No extended summary found
5859
59-
numpydoc/tests/hooks/example_module.py:26: SA01 See Also section not found
60+
{example_module!s}:26: SA01 See Also section not found
6061
61-
numpydoc/tests/hooks/example_module.py:26: EX01 No examples section found
62+
{example_module!s}:26: EX01 No examples section found
6263
63-
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
64+
{example_module!s}:30: GL08 The object does not have a docstring
6465
"""
6566
)
6667

@@ -76,18 +77,18 @@ def test_validate_hook_with_ignore(example_module, capsys):
7677
"""
7778

7879
expected = inspect.cleandoc(
79-
"""
80-
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
80+
f"""
81+
{example_module!s}:4: PR01 Parameters {{'name'}} not documented
8182
82-
numpydoc/tests/hooks/example_module.py:11: GL08 The object does not have a docstring
83+
{example_module!s}:11: GL08 The object does not have a docstring
8384
84-
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
85+
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented
8586
86-
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
87+
{example_module!s}:17: PR07 Parameter "*args" has no description
8788
88-
numpydoc/tests/hooks/example_module.py:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
89+
{example_module!s}:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
8990
90-
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
91+
{example_module!s}:30: GL08 The object does not have a docstring
9192
"""
9293
)
9394

@@ -123,14 +124,14 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
123124
)
124125

125126
expected = inspect.cleandoc(
126-
"""
127-
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
127+
f"""
128+
{example_module!s}:4: PR01 Parameters {{'name'}} not documented
128129
129-
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
130+
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented
130131
131-
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
132+
{example_module!s}:17: PR07 Parameter "*args" has no description
132133
133-
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
134+
{example_module!s}:30: GL08 The object does not have a docstring
134135
"""
135136
)
136137

@@ -158,14 +159,14 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
158159
)
159160

160161
expected = inspect.cleandoc(
161-
"""
162-
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
162+
f"""
163+
{example_module!s}:4: PR01 Parameters {{'name'}} not documented
163164
164-
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
165+
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented
165166
166-
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
167+
{example_module!s}:17: PR07 Parameter "*args" has no description
167168
168-
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
169+
{example_module!s}:30: GL08 The object does not have a docstring
169170
"""
170171
)
171172

@@ -203,10 +204,10 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys
203204
)
204205

205206
expected = inspect.cleandoc(
206-
"""
207-
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
207+
f"""
208+
{example_module!s}:4: PR01 Parameters {{'name'}} not documented
208209
209-
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
210+
{example_module!s}:30: GL08 The object does not have a docstring
210211
"""
211212
)
212213

@@ -234,12 +235,12 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
234235
)
235236

236237
expected = inspect.cleandoc(
237-
"""
238-
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
238+
f"""
239+
{example_module!s}:4: PR01 Parameters {{'name'}} not documented
239240
240-
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
241+
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented
241242
242-
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
243+
{example_module!s}:17: PR07 Parameter "*args" has no description
243244
"""
244245
)
245246

@@ -249,16 +250,17 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
249250

250251

251252
@pytest.mark.parametrize(
252-
"regex, expected_code",
253-
[(".*(/|\\\\)example.*\.py", 0), (".*/non_existent_match.*\.py", 1)],
253+
"file_exists, expected_code",
254+
[(True, 0), (False, 1)],
254255
)
255256
def test_validate_hook_exclude_files_option_pyproject(
256-
example_module, regex, expected_code, tmp_path
257+
example_module, file_exists, expected_code, tmp_path
257258
):
258259
"""
259260
Test that the hook correctly processes the toml config and either includes
260261
or excludes files based on the `exclude_files` option.
261262
"""
263+
exclude = str(example_module) if file_exists else "does_not_exist.py"
262264

263265
with open(tmp_path / "pyproject.toml", "w") as config_file:
264266
config_file.write(
@@ -276,7 +278,7 @@ def test_validate_hook_exclude_files_option_pyproject(
276278
'^Creates',
277279
]
278280
exclude_files = [
279-
'{regex}',
281+
'{re.escape(exclude)}',
280282
]"""
281283
)
282284
)
@@ -286,16 +288,17 @@ def test_validate_hook_exclude_files_option_pyproject(
286288

287289

288290
@pytest.mark.parametrize(
289-
"regex, expected_code",
290-
[(".*(/|\\\\)example.*\.py", 0), (".*/non_existent_match.*\.py", 1)],
291+
"file_exists, expected_code",
292+
[(True, 0), (False, 1)],
291293
)
292294
def test_validate_hook_exclude_files_option_setup_cfg(
293-
example_module, regex, expected_code, tmp_path
295+
example_module, file_exists, expected_code, tmp_path
294296
):
295297
"""
296298
Test that the hook correctly processes the setup config and either includes
297299
or excludes files based on the `exclude_files` option.
298300
"""
301+
exclude = str(example_module) if file_exists else "does_not_exist.py"
299302

300303
with open(tmp_path / "setup.cfg", "w") as config_file:
301304
config_file.write(
@@ -305,7 +308,7 @@ def test_validate_hook_exclude_files_option_setup_cfg(
305308
checks = all,EX01,SA01,ES01
306309
exclude = \\.NewClass$,\\.__init__$
307310
override_SS05 = ^Creates
308-
exclude_files = {regex}
311+
exclude_files = {re.escape(exclude)}
309312
"""
310313
)
311314
)

numpydoc/tests/test_docscrape.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from copy import deepcopy
66

77
import pytest
8-
from pytest import warns as assert_warns
98

109
from numpydoc.docscrape import ClassDoc, FunctionDoc, NumpyDocString, get_doc_object
1110

@@ -751,7 +750,7 @@ class Dummy:
751750

752751
def test_see_also_trailing_comma_warning():
753752
warnings.filterwarnings("error")
754-
with assert_warns(
753+
with pytest.warns(
755754
Warning,
756755
match="Unexpected comma or period after function list at index 43 of line .*",
757756
):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ default = [
4747
]
4848
dev = [
4949
'pre-commit>=3.3',
50-
"tomli; python_version < '3.11'",
5150
{ include-group = "doc" },
5251
{ include-group = "test" }
5352
]
@@ -171,6 +170,7 @@ attr = 'numpydoc.__version__'
171170
[tool.setuptools.package-data]
172171
numpydoc = [
173172
'tests/test_*.py',
173+
'tests/hooks/test_*.py',
174174
'tests/tinybuild/Makefile',
175175
'tests/tinybuild/index.rst',
176176
'tests/tinybuild/*.py',

0 commit comments

Comments
 (0)