Skip to content

Commit 4fbbd73

Browse files
dannyhyunkimPingviinituutti
authored andcommitted
DOC: Validate space before colon docstring parameters pandas-dev#23483 (pandas-dev#23506)
1 parent d0862a9 commit 4fbbd73

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

scripts/tests/test_validate_docstrings.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,8 @@ def test_bad_generic_functions(self, func):
761761
('BadParameters', 'missing_params',
762762
('Parameters {**kwargs} not documented',)),
763763
('BadParameters', 'bad_colon_spacing',
764-
('Parameters {kind} not documented',
765-
'Unknown parameters {kind: str}',
766-
'Parameter "kind: str" has no type')),
764+
('Parameter "kind" requires a space before the colon '
765+
'separating the parameter name and type',)),
767766
('BadParameters', 'no_description_period',
768767
('Parameter "kind" description should finish with "."',)),
769768
('BadParameters', 'no_description_period_with_directive',

scripts/validate_docstrings.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
'PR08': 'Parameter "{param_name}" description should start with a '
9898
'capital letter',
9999
'PR09': 'Parameter "{param_name}" description should finish with "."',
100+
'PR10': 'Parameter "{param_name}" requires a space before the colon '
101+
'separating the parameter name and type',
100102
'RT01': 'No Returns section found',
101103
'YD01': 'No Yields section found',
102104
'SA01': 'See Also section not found',
@@ -644,7 +646,11 @@ def validate_one(func_name):
644646
for param in doc.doc_parameters:
645647
if not param.startswith("*"): # Check can ignore var / kwargs
646648
if not doc.parameter_type(param):
647-
errs.append(error('PR04', param_name=param))
649+
if ':' in param:
650+
errs.append(error('PR10',
651+
param_name=param.split(':')[0]))
652+
else:
653+
errs.append(error('PR04', param_name=param))
648654
else:
649655
if doc.parameter_type(param)[-1] == '.':
650656
errs.append(error('PR05', param_name=param))

0 commit comments

Comments
 (0)