Skip to content

Commit b5b7e25

Browse files
authored
Fix validation bug when parameter type is set of options. (#347)
* Add test case. * Fix validation error when param_type is set of options.
1 parent 4ae1e00 commit b5b7e25

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

numpydoc/tests/test_validate.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,28 @@ def other_parameters(self, param1, param2):
458458
"""
459459
pass
460460

461+
def valid_options_in_parameter_description_sets(self, bar):
462+
"""
463+
Ensure a PR06 error is not raised when type is member of a set.
464+
465+
Literal keywords like 'integer' are valid when specified in a set of
466+
valid options for a keyword parameter.
467+
468+
Parameters
469+
----------
470+
bar : {'integer', 'boolean'}
471+
The literal values of 'integer' and 'boolean' are part of an
472+
options set and thus should not be subject to PR06 warnings.
473+
474+
See Also
475+
--------
476+
related : Something related.
477+
478+
Examples
479+
--------
480+
>>> result = 1 + 1
481+
"""
482+
461483

462484
class BadGenericDocStrings:
463485
"""Everything here has a bad docstring
@@ -1089,6 +1111,7 @@ def test_good_class(self, capsys):
10891111
"multiple_variables_on_one_line",
10901112
"other_parameters",
10911113
"warnings",
1114+
"valid_options_in_parameter_description_sets",
10921115
],
10931116
)
10941117
def test_good_functions(self, capsys, func):

numpydoc/validate.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ def validate(obj_name):
564564
else:
565565
if doc.parameter_type(param)[-1] == ".":
566566
errs.append(error("PR05", param_name=param))
567+
# skip common_type_error checks when the param type is a set of
568+
# options
569+
if "{" in doc.parameter_type(param):
570+
continue
567571
common_type_errors = [
568572
("integer", "int"),
569573
("boolean", "bool"),

0 commit comments

Comments
 (0)