Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change PR06 logic to only fail when type is used standalone #447

Merged
merged 4 commits into from
Jan 24, 2023
Merged
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
35 changes: 35 additions & 0 deletions numpydoc/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,40 @@ def parameters_with_trailing_underscores(self, str_):
"""
pass

def parameter_with_wrong_types_as_substrings(self, a, b, c, d, e, f):
r"""
Ensure PR06 doesn't fail when non-preferable types are substrings.

While PR06 checks for parameter types which contain non-preferable type
names like integer (int), string (str), and boolean (bool), PR06 should
not fail if those types are used only as susbtrings in, for example,
custom type names.

Parameters
----------
a : Myint
Some text.
b : intClass
Some text.
c : Mystring
Some text.
d : stringClass
Some text.
e : Mybool
Some text.
f : boolClass
Some text.

See Also
--------
related : Something related.

Examples
--------
>>> result = 1 + 1
"""
pass


class BadGenericDocStrings:
"""Everything here has a bad docstring"""
Expand Down Expand Up @@ -1145,6 +1179,7 @@ def test_good_class(self, capsys):
"warnings",
"valid_options_in_parameter_description_sets",
"parameters_with_trailing_underscores",
"parameter_with_wrong_types_as_substrings",
],
)
def test_good_functions(self, capsys, func):
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def validate(obj_name):
("string", "str"),
]
for wrong_type, right_type in common_type_errors:
if wrong_type in doc.parameter_type(param):
amoeba marked this conversation as resolved.
Show resolved Hide resolved
if wrong_type in set(re.split(r"\W", doc.parameter_type(param))):
errs.append(
error(
"PR06",
Expand Down