diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 080affab..87daee17 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -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""" @@ -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): diff --git a/numpydoc/validate.py b/numpydoc/validate.py index cc058f0d..b975f831 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -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): + if wrong_type in set(re.split(r"\W", doc.parameter_type(param))): errs.append( error( "PR06",