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

gh-100989: Fix docstrings of collections.deque #100990

Conversation

timobrembeck
Copy link
Contributor

See gh-100989 for the issue description.

Thanks in advance for your feedback!

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Jan 12, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@timobrembeck
Copy link
Contributor Author

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

In my opinion, it doesn't, but let me know if you think the bot is right.

@timobrembeck timobrembeck force-pushed the gh-100989-fix-collections-deque-docstrings branch from 6a66e8a to 072515c Compare February 3, 2023 12:14
@bedevere-bot

This comment was marked as outdated.

@arhadthedev arhadthedev added skip news extension-modules C modules in the Modules dir labels Feb 3, 2023
@timobrembeck timobrembeck force-pushed the gh-100989-fix-collections-deque-docstrings branch from 072515c to d5a4557 Compare February 15, 2023 23:42
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard reminder: You can directly apply all the suggestions you want in one go with Files changed -> Add to batch -> Commit

This change seems to have value overall, as it not only fixes the downstream Sphinx warnings, but is clearer and more explicit as well as more concise and consistent as to the parameter and return types of these methods (per Diataxis for reference docs), and provides much clearer and more detailed descriptions that fill in key missing details as to what the parameters actually do.

I did have a couple minor suggestions, see comments. Also, it would be good for someone familiar with both the docs and the C-API (like @erlend-aasland ) should probably also take a look at it. Thanks!

Modules/_collectionsmodule.c Show resolved Hide resolved
Modules/_collectionsmodule.c Outdated Show resolved Hide resolved
@CAM-Gerlach CAM-Gerlach added docs Documentation in the Doc dir needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Feb 25, 2023
@timobrembeck timobrembeck force-pushed the gh-100989-fix-collections-deque-docstrings branch 2 times, most recently from c8824dc to 47ceeed Compare February 25, 2023 09:53
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from my side from one trivial fix to my own typo. Thanks!

Modules/_collectionsmodule.c Outdated Show resolved Hide resolved
@CAM-Gerlach CAM-Gerlach removed the extension-modules C modules in the Modules dir label Feb 25, 2023
@timobrembeck timobrembeck force-pushed the gh-100989-fix-collections-deque-docstrings branch from cae4944 to eb1219d Compare February 25, 2023 10:08
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing that Raymond (the code owner) specifically requested only the integer => int change to be applied, I think it would better to reduce this PR to that specific change only.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@timobrembeck
Copy link
Contributor Author

Seeing that Raymond (the code owner) specifically requested only the integer => int change to be applied, I think it would better to reduce this PR to that specific change only.

@erlend-aasland Thanks a lot for your thoughts on this. As explained in #100989 (comment), this suggested change would not solve the Sphinx warning, since Sphinx does not recognize the -- pattern as separation of type and description. I would open a ticket on Sphinx' side if this code style is somehow a defined standard other projects should respect, but I did not find any resources on this. Do you know more about this, or in general a guideline docstrings should follow?

The smallest possible changes that would resolve the warning would be to also replace -- by two new lines, do you think this would be justified as well?

I still think that if the documentation of PyDoc_STRVAR tells us that we should write the docstrings according to PEP-7, we should do one of two things:

  1. Actually write the docstrings according to that guideline
  2. Or remove that passage from the docs and either require a (newer?) guideline or state that docstrings don't have to follow any specific formatting (in which case I would suggest that we also don't use the signature-like format function(params) -> return type (but not really), because it makes other tools like e.g. Sphinx' autodoc_docstring_signature think it's a machine parsable format, which it is not in that case).

@erlend-aasland
Copy link
Contributor

@timoludwig: thanks for the explanation! I'll review it with this in mind.

@CAM-Gerlach
Copy link
Member

And just to note, the eventual changes are AFAIK substantially modified and refined from those that the core dev in question initially was hesitant about on first glance. IMO, the much greater value here is not the specific Sphinx or formatting issue, but rather the substantial increase in clarity, consistency and completeness per the Diatxis guidelines for API reference documentation, particularly for the target audience users who may not be experts in the usage of the code in question.

@miss-islington
Copy link
Contributor

Thanks @timoludwig for the PR, and @erlend-aasland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 22, 2023
…pythonGH-100990)

(cherry picked from commit c740736)

Co-authored-by: Timo Ludwig <ti.ludwig@web.de>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@bedevere-bot
Copy link

GH-102910 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Mar 22, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 22, 2023
…pythonGH-100990)

(cherry picked from commit c740736)

Co-authored-by: Timo Ludwig <ti.ludwig@web.de>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@bedevere-bot
Copy link

GH-102911 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Mar 22, 2023
@timobrembeck timobrembeck deleted the gh-100989-fix-collections-deque-docstrings branch March 22, 2023 11:49
miss-islington added a commit that referenced this pull request Mar 22, 2023
…00990)

(cherry picked from commit c740736)

Co-authored-by: Timo Ludwig <ti.ludwig@web.de>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
miss-islington added a commit that referenced this pull request Mar 22, 2023
…00990)

(cherry picked from commit c740736)

Co-authored-by: Timo Ludwig <ti.ludwig@web.de>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
timobrembeck added a commit to timobrembeck/cpython that referenced this pull request Mar 23, 2023
rhettinger added a commit to rhettinger/cpython that referenced this pull request Mar 23, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants