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

pydocstyle rules should follow naming convention #15009

Open
dylwil3 opened this issue Dec 16, 2024 · 11 comments · May be fixed by #15102
Open

pydocstyle rules should follow naming convention #15009

dylwil3 opened this issue Dec 16, 2024 · 11 comments · May be fixed by #15102
Assignees
Labels
docstring Related to docstring linting or formatting documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@dylwil3
Copy link
Collaborator

dylwil3 commented Dec 16, 2024

The following rules should be renamed to conform to Ruff's naming convention:

  • fits-on-one-line (D200)
  • no-blank-line-before-function (D201)
  • no-blank-line-after-function (D202)
  • one-blank-line-before-class (D203)
  • one-blank-line-after-class (D204)
  • blank-line-after-summary (D205)
  • indent-with-spaces (D206)
  • section-not-overindented (D214)
  • section-underline-not-overindented (D215)
  • ends-in-period (D400)
  • no-signature (D402)
  • capitalize-section-name (D405)
  • new-line-after-section-name (D406)
  • dashed-underline-after-section (D407)
  • section-underline-after-name (D408)
  • section-underline-matches-section-length (D409)
  • blank-line-after-last-section (D413)
  • ends-in-punctuation (D415)
  • section-name-ends-in-colon (D416)

[Apologies if any of these are in error - double negating on the fly may have spun my head around]

@dylwil3 dylwil3 added documentation Improvements or additions to documentation good first issue Good for newcomers labels Dec 16, 2024
@dhruvmanila
Copy link
Member

We'll also need to add redirects for the documentation website.

@AlexWaygood AlexWaygood added the docstring Related to docstring linting or formatting label Dec 16, 2024
@enochkan
Copy link

Hi all! I'd like to work on this issue.

Is the idea to rename no-blank-line-before-function to blank-line-before-function since it highlights the pattern being linted against?

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Dec 21, 2024

Right! You want it to be grammatically correct to say "allow (rule name)" if you want to turn off the lint rule.

And great, thanks for your help!

@enochkan
Copy link

No problem @dylwil3 happy to help :)

I'll confirm the naming conventions with you before making any changes.

@enochkan
Copy link

enochkan commented Dec 21, 2024

Code Old Name New Name Rationale
D200 fits-on-one-line unnecessary-multiline-docstring Flags docstrings that should fit on one line but are written over multiple lines.
D201 no-blank-line-before-function blank-line-before-function Flags the presence of a blank line before a function definition.
D202 no-blank-line-after-function blank-line-after-function Flags the presence of a blank line immediately after a function definition.
D203 one-blank-line-before-class incorrect-blank-line-before-class Flags incorrect blank lines (missing or extra) before a class definition.
D204 one-blank-line-after-class incorrect-blank-line-after-class Flags incorrect blank lines (missing or extra) after a class definition.
D205 blank-line-after-summary missing-blank-line-after-summary Flags a docstring summary line that is not followed by a blank line.
D206 indent-with-spaces docstring-tab-indentation Flags the use of tabs where spaces are required (e.g., in docstring indentation).
D214 section-not-overindented overindented-section Flags a docstring section that is indented more than the surrounding docstring lines.
D215 section-underline-not-overindented overindented-section-underline Flags a section underline that is indented more than the section text itself.
D400 ends-in-period missing-trailing-period Flags a docstring that does not end with a period.
D402 no-signature signature-in-docstring Flags function signatures that appear inside docstrings.
D405 capitalize-section-name non-capitalized-section-name Flags docstring section names that do not start with a capital letter.
D406 new-line-after-section-name missing-new-line-after-section-name Flags the absence of a newline immediately after a docstring section name.
D407 dashed-underline-after-section missing-dashed-underline-after-section Flags a docstring section without the required dashed underline beneath it.
D408 section-underline-after-name missing-section-underline-after-name Flags a missing section underline directly after a docstring section name.
D409 section-underline-matches-section-length mismatched-section-underline-length Flags an underline whose length does not match its section name length.
D413 blank-line-after-last-section missing-blank-line-after-last-section Flags the lack of a blank line after the final docstring section.
D415 ends-in-punctuation missing-terminal-punctuation Flags docstrings that do not end with the required punctuation (e.g., a period).
D416 section-name-ends-in-colon missing-section-name-colon Flags a docstring section name that does not end in a colon.

@dylwil3 thoughts?

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Dec 22, 2024

Looks good to me, very thorough @enochkan ! I'd welcome a PR - let me know if you need help sorting out where to change the name. Thanks again!

@enochkan
Copy link

@dylwil3 actually I probably need some help :P

did a quick search and found most occurrences in faq.md?

Image

@enochkan
Copy link

oh no, I'm guessing all the occurrences in test cases need to change as well:

Image

@enochkan
Copy link

enochkan commented Dec 22, 2024

I've found occurrences in these places so far:

Code Old Name Occurring in
D200 fits-on-one-line codes.rs, definitions.rs, mod.rs, one_liner.rs
D201 no-blank-line-before-function codes.rs, definitions.rs, mod.rs, one_liner.rs, blank_before_after_function.rs, check_docs_formatted.py
D202 no-blank-line-after-function codes.rs, definitions.rs, mod.rs, one_liner.rs, blank_before_after_function.rs, D202.py
D203 one-blank-line-before-class format.rs, codes.rs, definitions.rs, mod.rs, settings.rs, blank_before_after_class.rs, integration_test.rs, registry.rs, faq.md, check_docs_formatted.py
D204 one-blank-line-after-class codes.rs, definitions.rs, mod.rs, settings.rs, blank_before_after_class.rs, faq.md, check_docs_formatted.py
D205 blank-line-after-summary codes.rs, definitions.rs, mod.rs, blank_after_summary.rs
D206 indent-with-spaces format.rs, codes.rs, definitions.rs, mod.rs, indent.rs, formatter.md, check_docs_formatted.py
D214 section-not-overindented codes.rs, definitions.rs, mod.rs, settings.rs, sections.rs, faq.md
D215 section-underline-not-overindented codes.rs, definitions.rs, mod.rs, settings.rs, sections.rs, faq.md
D400 ends-in-period codes.rs, definitions.rs, mods.rs, settings.rs, ends_with_period.rs, faq.md
D402 no-signature codes.rs, definitions.rs, mods.rs, settings.rs, no_signature.rs, faq.md
D405 capitalize-section-name codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs
D406 new-line-after-section-name codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs, faq.md
D407 dashed-underline-after-section codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs, faq.md
D408 section-underline-after-name codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs, faq.md
D409 section-underline-matches-section-length codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs, faq.md
D413 blank-line-after-last-section codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs
D415 ends-in-punctuation codes.rs, definitions.rs, mods.rs, settings.rs, ends_with_punction.rs, faq.md
D416 section-name-ends-in-colon codes.rs, definitions.rs, mods.rs, settings.rs, sections.rs, faq.md

@dylwil3 anything else?

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Dec 22, 2024

@enochkan Sure! Let's walk through the steps to change fits-on-one-line to unnecessary-multiline-docstring.

  1. Change all occurrences of this struct name
    pub(crate) struct FitsOnOneLine;

    to UnnecessaryMultilineDocstring. Hopefully you have an IDE that will do most of this for you, otherwise you'll have to go (rip)grep hunting. (Or you can just keep running cargo check and letting it yell at you).
  2. Optionally, change the name of the function that checks for the violation if it seems confusing (in this case the function's name is one_liner so it already isn't tied to the name of the rule, you can leave it as-is.)
  3. A small selection of the documentation website is not auto-generated and may reference rules, which you found in this case in the FAQ. So you'll have to change those as well.
  4. Probably a good idea to (rip)grep for other occurences of the name, both in hyphenated and camel case form, to see if anything was missed. It looks like you did this and found some spurious references in other files (e.g. scripts), so that's great.

If it helps here's an example PR implementing a name change: #12399

In any event, maybe it's easiest from here just to open a PR and we can hunt for any missing changes from there - the code compiling will already be a positive signal.

Thanks for your diligence!

@enochkan
Copy link

@dylwil3 added #15102.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Related to docstring linting or formatting documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants