Skip to content

Commit 4b09325

Browse files
committed
Merge branch 'ConstructorChecking_ASTValidator' of https://github.com/mattgebert/numpydoc into ConstructorChecking_ASTValidator
2 parents 92d8305 + 2703b22 commit 4b09325

File tree

8 files changed

+24
-23
lines changed

8 files changed

+24
-23
lines changed

.github/workflows/milestone-merged-prs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: attach to PR
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: scientific-python/attach-next-milestone-action@bc07be829f693829263e57d5e8489f4e57d3d420
15+
- uses: scientific-python/attach-next-milestone-action@c9cfab10ad0c67fed91b01103db26b7f16634639
1616
with:
1717
token: ${{ secrets.MILESTONE_LABELER_TOKEN }}
1818
force: true

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
27+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2828
with:
2929
name: dist
3030
path: dist
@@ -40,7 +40,7 @@ jobs:
4040
# IMPORTANT: this permission is mandatory for trusted publishing
4141
id-token: write
4242
steps:
43-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
43+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
4444
with:
4545
name: dist
4646
path: dist

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
args: [--prose-wrap=preserve]
2626

2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: "89c421dff2e1026ba12cdb9ebd731f4a83aa8021" # frozen: v0.8.6
28+
rev: "971923581912ef60a6b70dbf0c3e9a39563c9d47" # frozen: v0.11.4
2929
hooks:
3030
- id: ruff
3131
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]

numpydoc/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ def _parse_config(s):
104104
nargs="*",
105105
help=(
106106
f"""Check codes to ignore.{
107-
' Currently ignoring the following from '
108-
f'{Path(project_root_from_cwd) / config_file}: {ignored_checks_text}'
109-
'Values provided here will be in addition to the above, unless an alternate config is provided.'
110-
if ignored_checks else ''
107+
" Currently ignoring the following from "
108+
f"{Path(project_root_from_cwd) / config_file}: {ignored_checks_text}"
109+
"Values provided here will be in addition to the above, unless an alternate config is provided."
110+
if ignored_checks
111+
else ""
111112
}"""
112113
),
113114
)

numpydoc/docscrape.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ def _parse_param_list(self, content, single_element_is_type=False):
232232
# NOTE: param line with single element should never have a
233233
# a " :" before the description line, so this should probably
234234
# warn.
235-
if header.endswith(" :"):
236-
header = header[:-2]
235+
header = header.removesuffix(" :")
237236
if single_element_is_type:
238237
arg_name, arg_type = "", header
239238
else:

numpydoc/tests/hooks/example_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def do_something(self, *args, **kwargs):
2323
*args
2424
"""
2525

26-
def process(self):
27-
"""Process stuff."""
26+
def create(self):
27+
"""Creates stuff."""
2828

2929

3030
class NewClass:

numpydoc/tests/hooks/test_validate_hook.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
116116
]
117117
exclude = '\\.__init__$'
118118
override_SS05 = [
119-
'^Process',
120-
'^Assess',
121-
'^Access',
119+
'^Creates',
122120
]
123121
"""
124122
)
@@ -154,7 +152,7 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
154152
[tool:numpydoc_validation]
155153
checks = all,EX01,SA01,ES01
156154
exclude = \\.__init__$
157-
override_SS05 = ^Process,^Assess,^Access
155+
override_SS05 = ^Creates
158156
"""
159157
)
160158
)
@@ -198,9 +196,7 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys
198196
'\.__init__$',
199197
]
200198
override_SS05 = [
201-
'^Process',
202-
'^Assess',
203-
'^Access',
199+
'^Creates',
204200
]
205201
"""
206202
)
@@ -232,7 +228,7 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
232228
[tool:numpydoc_validation]
233229
checks = all,EX01,SA01,ES01
234230
exclude = \\.NewClass$,\\.__init__$
235-
override_SS05 = ^Process,^Assess,^Access
231+
override_SS05 = ^Creates
236232
"""
237233
)
238234
)

numpydoc/validate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@
8080
"PR06": 'Parameter "{param_name}" type should use "{right_type}" instead '
8181
'of "{wrong_type}"',
8282
"PR07": 'Parameter "{param_name}" has no description',
83-
"PR08": 'Parameter "{param_name}" description should start with a '
84-
"capital letter",
83+
"PR08": 'Parameter "{param_name}" description should start with a capital letter',
8584
"PR09": 'Parameter "{param_name}" description should finish with "."',
8685
"PR10": 'Parameter "{param_name}" requires a space before the colon '
8786
"separating the parameter name and type",
@@ -750,7 +749,13 @@ def validate(obj_name, validator_cls=None, **validator_kwargs):
750749
errs.append(error("SS03"))
751750
if doc.summary != doc.summary.lstrip():
752751
errs.append(error("SS04"))
753-
elif doc.is_function_or_method and doc.summary.split(" ")[0][-1] == "s":
752+
# Heuristic to check for infinitive verbs - shouldn't end in "s"
753+
elif (
754+
doc.is_function_or_method
755+
and len(doc.summary.split(" ")[0]) > 1
756+
and doc.summary.split(" ")[0][-1] == "s"
757+
and doc.summary.split(" ")[0][-2] != "s"
758+
):
754759
errs.append(error("SS05"))
755760
if doc.num_summary_lines > 1:
756761
errs.append(error("SS06"))

0 commit comments

Comments
 (0)