diff --git a/scripts/tests/test_validate_docstrings.py b/scripts/tests/test_validate_docstrings.py index c1bdab73c26715..60b60603f02890 100644 --- a/scripts/tests/test_validate_docstrings.py +++ b/scripts/tests/test_validate_docstrings.py @@ -761,9 +761,8 @@ def test_bad_generic_functions(self, func): ('BadParameters', 'missing_params', ('Parameters {**kwargs} not documented',)), ('BadParameters', 'bad_colon_spacing', - ('Parameters {kind} not documented', - 'Unknown parameters {kind: str}', - 'Parameter "kind: str" has no type')), + ('Parameter "kind" requires a space before the colon ' + 'separating the parameter name and type',)), ('BadParameters', 'no_description_period', ('Parameter "kind" description should finish with "."',)), ('BadParameters', 'no_description_period_with_directive', diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index 7da77a1f60ad51..873ba71d6539d6 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -97,6 +97,8 @@ 'PR08': 'Parameter "{param_name}" description should start with a ' 'capital letter', 'PR09': 'Parameter "{param_name}" description should finish with "."', + 'PR10': 'Parameter "{param_name}" requires a space before the colon ' + 'separating the parameter name and type', 'RT01': 'No Returns section found', 'YD01': 'No Yields section found', 'SA01': 'See Also section not found', @@ -644,7 +646,11 @@ def validate_one(func_name): for param in doc.doc_parameters: if not param.startswith("*"): # Check can ignore var / kwargs if not doc.parameter_type(param): - errs.append(error('PR04', param_name=param)) + if ':' in param: + errs.append(error('PR10', + param_name=param.split(':')[0])) + else: + errs.append(error('PR04', param_name=param)) else: if doc.parameter_type(param)[-1] == '.': errs.append(error('PR05', param_name=param))