Skip to content

Docstring validation script: handle args/kwargs #20072

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

Closed
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
12 changes: 8 additions & 4 deletions scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def needs_summary(self):

@property
def doc_parameters(self):
return collections.OrderedDict((name, (type_, ''.join(desc)))
for name, type_, desc
in self.doc['Parameters'])
return collections.OrderedDict(
(name.strip('*'), (type_, ''.join(desc)))
for name, type_, desc in self.doc['Parameters'])

@property
def signature_parameters(self):
Expand Down Expand Up @@ -417,7 +417,11 @@ def validate_one(func_name):

param_errs = doc.parameter_mismatches
for param in doc.doc_parameters:
if not doc.parameter_type(param):
if param in {'kwargs', 'args'}:
if doc.parameter_type(param):
param_errs.append('Parameter "**{}" does not need a type '
'description'.format(param))
elif not doc.parameter_type(param) and param not in {'args', 'kwargs'}:
param_errs.append('Parameter "{}" has no type'.format(param))
else:
if doc.parameter_type(param)[-1] == '.':
Expand Down