Skip to content
Open
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
32 changes: 32 additions & 0 deletions numpydoc/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down
35 changes: 18 additions & 17 deletions numpydoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down