Closed
Description
One of the validations performed in the docstrings in validate_docstrings.py
is whether a Returns
section is present. So far we just check if the return
word exist in the source code, and if it does, we generate an error if the docsting does not have the documentation section.
But this causes false positives, see this case:
def say_hello(lang):
"""
This function does not have a Returns section.
This is correct because nothing is returned.
Parameters
----------
lang : str
Language to say hello in.
"""
if lang not in ('en', 'es'):
return
print({'en': 'Hi!', 'es': 'Hola!'}[lang])
The return
keyword is found in the code, so the presence of a Returns
section is validated, but it should not.
Without making anything complicated, it'd be nice to check when validating:
- That the return words found are not a bare return or a
return None
or are not comments...
If any code return
is found that does not return always None
is found, then we should show the error.