Skip to content

BUG: Correct functionality of numpydoc SS05 #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions numpydoc/tests/hooks/example_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def do_something(self, *args, **kwargs):
*args
"""

def process(self):
"""Process stuff."""
def create(self):
"""Creates stuff."""


class NewClass:
Expand Down
12 changes: 4 additions & 8 deletions numpydoc/tests/hooks/test_validate_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
]
exclude = '\\.__init__$'
override_SS05 = [
'^Process',
'^Assess',
'^Access',
'^Creates',
]
"""
)
Expand Down Expand Up @@ -154,7 +152,7 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
[tool:numpydoc_validation]
checks = all,EX01,SA01,ES01
exclude = \\.__init__$
override_SS05 = ^Process,^Assess,^Access
override_SS05 = ^Creates
"""
)
)
Expand Down Expand Up @@ -198,9 +196,7 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys
'\.__init__$',
]
override_SS05 = [
'^Process',
'^Assess',
'^Access',
'^Creates',
]
"""
)
Expand Down Expand Up @@ -232,7 +228,7 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
[tool:numpydoc_validation]
checks = all,EX01,SA01,ES01
exclude = \\.NewClass$,\\.__init__$
override_SS05 = ^Process,^Assess,^Access
override_SS05 = ^Creates
"""
)
)
Expand Down
8 changes: 7 additions & 1 deletion numpydoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,13 @@ def validate(obj_name, validator_cls=None, **validator_kwargs):
errs.append(error("SS03"))
if doc.summary != doc.summary.lstrip():
errs.append(error("SS04"))
elif doc.is_function_or_method and doc.summary.split(" ")[0][-1] == "s":
# Heuristic to check for infinitive verbs - shouldn't end in "s"
elif (
doc.is_function_or_method
and len(doc.summary.split(" ")[0]) > 1
and doc.summary.split(" ")[0][-1] == "s"
and doc.summary.split(" ")[0][-2] != "s"
):
errs.append(error("SS05"))
if doc.num_summary_lines > 1:
errs.append(error("SS06"))
Expand Down