From 11f9ae0b1b5e6c7d3040438c25280d5679126c44 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 6 Jan 2022 12:27:32 -0800 Subject: [PATCH 1/2] Add test case. --- numpydoc/tests/test_validate.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index ecbe7031..60cebcdc 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -458,6 +458,28 @@ def other_parameters(self, param1, param2): """ pass + def valid_options_in_parameter_description_sets(self, bar): + """ + Ensure a PR06 error is not raised when type is member of a set. + + Literal keywords like 'integer' are valid when specified in a set of + valid options for a keyword parameter. + + Parameters + ---------- + bar : {'integer', 'boolean'} + The literal values of 'integer' and 'boolean' are part of an + options set and thus should not be subject to PR06 warnings. + + See Also + -------- + related : Something related. + + Examples + -------- + >>> result = 1 + 1 + """ + class BadGenericDocStrings: """Everything here has a bad docstring @@ -1089,6 +1111,7 @@ def test_good_class(self, capsys): "multiple_variables_on_one_line", "other_parameters", "warnings", + "valid_options_in_parameter_description_sets", ], ) def test_good_functions(self, capsys, func): From eac84ceb478ed632c94ef8fe2a7bfb9f304585bc Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Thu, 6 Jan 2022 12:31:50 -0800 Subject: [PATCH 2/2] Fix validation error when param_type is set of options. --- numpydoc/validate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/numpydoc/validate.py b/numpydoc/validate.py index 91aca6b1..36757379 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -564,6 +564,10 @@ def validate(obj_name): else: 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"),