question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: Validate the Returns section in the docstrings

See original GitHub issue

scripts/validate_docstrings.py validates that the content of a docstring follows our standards. There are still some of those standards that the script does not validate, and this gives the users the wrong impression that the docstring is all right, when it’s not really the case. All the missing validations are listed in #20298.

The format of the Returns section consists of a first line with just the type, and afterwards indented the description. In the case a tuple is returned, then the format is name : type or types for each parameter, and indented descriptions after them. The descriptions need to start with a capital letter and finish with a period. See: https://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html#section-4-returns-or-yields

For this issue is required:

  • Change scripts/validate_docstings.py to give errors if some of the described formats are not satisfied.
  • Add tests in scripts/tests/test_validate_docstrings.py

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
datapythonistacommented, Oct 14, 2018

In this case it should fail because there is a single value being returned, and it contains the name obj_head.

The correct cases are:

Returns
--------
int
    The single integer value that the function returns.
Returns
--------
id : int
    The function returns a tuple, and the first value is an integer with the id.
name : str
    The second value of the tuple is a string with the name.
0reactions
igorfassencommented, Oct 31, 2018

I’ve added some checks in validate_docstrings.py, and some corresponding tests.

i’ve created the following pull request : #23432

(sorry, i’m not very familiar with github, i hope I’ve done this the right way…)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation — numpydoc v1.6.0rc1.dev0 Manual - Read the Docs
This will validate that the docstring can be built. For an exhaustive validation of the formatting of the docstring, use the --validate parameter....
Read more >
Python Docstring: Documenting And Introspecting Functions
This tutorial explains what is Python Docstring and how to use it to document Python functions with examples.
Read more >
DOC: docstring validation script improvements #20298 - GitHub
Returns section : first line with type only if a single return, desc starting with capital and ending with period... ( DOC: Validate...
Read more >
doctest — Test interactive Python examples — Python 3.11.1 ...
This section examines in detail how doctest works: which docstrings it looks at, how it finds interactive examples, what execution context it uses,...
Read more >
Documenting Python APIs with Docstrings
ReStructuredText in Docstrings. Numpydoc Sections in Docstrings. Short Summary; Deprecation Warning; Extended Summary; Parameters; Returns or Yields ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found