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

DOC: Validate space before colon docstring parameters #23483 #23506

Merged
merged 2 commits into from
Nov 15, 2018
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
5 changes: 2 additions & 3 deletions scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 7 additions & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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))
Expand Down