From 4d0f088e39017cd7afddfd6d3389d684047212fd Mon Sep 17 00:00:00 2001 From: Maxine Hartnett Date: Tue, 11 Mar 2025 17:05:28 -0600 Subject: [PATCH 1/3] 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." --- numpydoc/validate.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/numpydoc/validate.py b/numpydoc/validate.py index 858a06d2..324090ae 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -711,7 +711,12 @@ 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 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")) From 3736c6110e7b7c863b70fc405fa65a02f84578e6 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Tue, 15 Apr 2025 12:54:57 -0400 Subject: [PATCH 2/3] Update numpydoc/validate.py --- numpydoc/validate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/numpydoc/validate.py b/numpydoc/validate.py index 324090ae..58a29ad9 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -714,6 +714,7 @@ def validate(obj_name, validator_cls=None, **validator_kwargs): # 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" ): From 2c75f13c24afb40bcee8f161676cf54a9fdecf38 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Tue, 15 Apr 2025 13:12:44 -0400 Subject: [PATCH 3/3] FIX: Overrides --- numpydoc/tests/hooks/example_module.py | 4 ++-- numpydoc/tests/hooks/test_validate_hook.py | 12 ++++-------- numpydoc/validate.py | 3 +-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/numpydoc/tests/hooks/example_module.py b/numpydoc/tests/hooks/example_module.py index 87e9b52d..9f75bdf0 100644 --- a/numpydoc/tests/hooks/example_module.py +++ b/numpydoc/tests/hooks/example_module.py @@ -23,8 +23,8 @@ def do_something(self, *args, **kwargs): *args """ - def process(self): - """Process stuff.""" + def create(self): + """Creates stuff.""" class NewClass: diff --git a/numpydoc/tests/hooks/test_validate_hook.py b/numpydoc/tests/hooks/test_validate_hook.py index 25851db5..47f315c2 100644 --- a/numpydoc/tests/hooks/test_validate_hook.py +++ b/numpydoc/tests/hooks/test_validate_hook.py @@ -116,9 +116,7 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys): ] exclude = '\\.__init__$' override_SS05 = [ - '^Process', - '^Assess', - '^Access', + '^Creates', ] """ ) @@ -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 """ ) ) @@ -198,9 +196,7 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys '\.__init__$', ] override_SS05 = [ - '^Process', - '^Assess', - '^Access', + '^Creates', ] """ ) @@ -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 """ ) ) diff --git a/numpydoc/validate.py b/numpydoc/validate.py index 58a29ad9..d0debfa2 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -80,8 +80,7 @@ "PR06": 'Parameter "{param_name}" type should use "{right_type}" instead ' 'of "{wrong_type}"', "PR07": 'Parameter "{param_name}" has no description', - "PR08": 'Parameter "{param_name}" description should start with a ' - "capital letter", + "PR08": 'Parameter "{param_name}" description should start with a capital letter', "PR09": 'Parameter "{param_name}" description should finish with "."', "PR10": 'Parameter "{param_name}" requires a space before the colon ' "separating the parameter name and type",