Skip to content

Commit 5b437b5

Browse files
maxinelasplarsoner
andauthored
BUG: Correct functionality of numpydoc SS05 (#613)
* BUG: Correct functionality of numpydoc SS05. Currently SS05 checks for infinitive verbs by checking if the last character is "s". However, if the first word is "process", which is valid, this incorrectly throws a numpydoc validation error. This commit allows the first word to end in two "s"es without flagging as an error. This will allow for words like "process" or "progress," while still checking for invalid words like "creates." * Update numpydoc/validate.py * FIX: Overrides --------- Co-authored-by: Eric Larson <[email protected]>
1 parent 08bf5f9 commit 5b437b5

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Diff for: numpydoc/tests/hooks/example_module.py

+2-2
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:

Diff for: numpydoc/tests/hooks/test_validate_hook.py

+4-8
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
)

Diff for: numpydoc/validate.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,13 @@ def validate(obj_name, validator_cls=None, **validator_kwargs):
710710
errs.append(error("SS03"))
711711
if doc.summary != doc.summary.lstrip():
712712
errs.append(error("SS04"))
713-
elif doc.is_function_or_method and doc.summary.split(" ")[0][-1] == "s":
713+
# Heuristic to check for infinitive verbs - shouldn't end in "s"
714+
elif (
715+
doc.is_function_or_method
716+
and len(doc.summary.split(" ")[0]) > 1
717+
and doc.summary.split(" ")[0][-1] == "s"
718+
and doc.summary.split(" ")[0][-2] != "s"
719+
):
714720
errs.append(error("SS05"))
715721
if doc.num_summary_lines > 1:
716722
errs.append(error("SS06"))

0 commit comments

Comments
 (0)