From baa8cccafcc5325f73b23dc9cd4672ff59a33b47 Mon Sep 17 00:00:00 2001 From: Dylan Pulver Date: Wed, 26 Aug 2026 11:17:08 +0300 Subject: [PATCH] fix: keep PR07-PR09 checks for option-set parameter types The guard added in #347 suppresses the common-type (PR06) checks when a parameter type is a set of options. It does so with a continue, which advances the parameter loop and therefore also skips the _check_desc call at the end of the loop body, silently disabling PR07, PR08 and PR09 for those parameters. Negate the guard instead so only the PR06 block is skipped. --- numpydoc/tests/test_validate.py | 32 ++++++++++++++++++++++++++++++ numpydoc/validate.py | 35 +++++++++++++++++---------------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index ca08b006..0215e326 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -999,6 +999,25 @@ def parameter_capitalization(self, kind): this is not capitalized. """ + def option_set_no_description(self, kind): + """ + Lacks the description, with a set of options as the type. + + Parameters + ---------- + kind : {'integer', 'boolean'} + """ + + def option_set_bad_description(self, kind): + """ + Forgets to capitalize and to end with a period, with an options set type. + + Parameters + ---------- + kind : {'integer', 'boolean'} + this doesn't end with a dot + """ + def blank_lines(self, kind): """ Adds a blank line after the section header. @@ -1652,6 +1671,19 @@ def test_bad_generic_functions(self, capsys, func): "parameter_capitalization", ('Parameter "kind" description should start with a capital letter',), ), + ( + "BadParameters", + "option_set_no_description", + ('Parameter "kind" has no description',), + ), + ( + "BadParameters", + "option_set_bad_description", + ( + 'Parameter "kind" description should start with a capital letter', + 'Parameter "kind" description should finish with "."', + ), + ), ( "BadParameters", "integer_parameter", diff --git a/numpydoc/validate.py b/numpydoc/validate.py index fc6c819a..511b6172 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -791,24 +791,25 @@ def validate(obj_name, validator_cls=None, **validator_kwargs): if doc.parameter_type(param)[-1] == ".": errs.append(error("PR05", param_name=param)) # skip common_type_error checks when the param type is a set of - # options - if "{" in doc.parameter_type(param): - continue - common_type_errors = [ - ("integer", "int"), - ("boolean", "bool"), - ("string", "str"), - ] - for wrong_type, right_type in common_type_errors: - if wrong_type in set(re.split(r"\W", doc.parameter_type(param))): - errs.append( - error( - "PR06", - param_name=param, - right_type=right_type, - wrong_type=wrong_type, + # options; the description checks below still apply + if "{" not in doc.parameter_type(param): + common_type_errors = [ + ("integer", "int"), + ("boolean", "bool"), + ("string", "str"), + ] + for wrong_type, right_type in common_type_errors: + if wrong_type in set( + re.split(r"\W", doc.parameter_type(param)) + ): + errs.append( + error( + "PR06", + param_name=param, + right_type=right_type, + wrong_type=wrong_type, + ) ) - ) errs.extend(_check_desc(kind_desc[1], "PR07", "PR08", "PR09", param_name=param)) if doc.is_function_or_method: