Skip to content

D403: Require capitalizing single word sentence#10776

Merged
MichaReiser merged 2 commits intomainfrom
d403-single-word
Apr 5, 2024
Merged

D403: Require capitalizing single word sentence#10776
MichaReiser merged 2 commits intomainfrom
d403-single-word

Conversation

@MichaReiser
Copy link
Member

Summary

Closes #10775

D403 requires capitalizing the first word in docstrings, but only if the word is all ASCII letters (e.g. not a .).

D403 doesn't enforce capitalizing the first word today if it consists of a single word terminated by a . because a . is not an ASCII letter.
This matches pydocstyles behavior. However, it doesn enforce capitalizing the first word if it isn't terminated with a .

This PR fixes D403 to also flag docstrings that start with a single word terminated with a ..

Test Plan

Added unit tests

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Apr 4, 2024
Comment on lines +79 to +86
// Like pydocstyle, we only support ASCII for now.
for char in first_word.chars().skip(1) {
if !char.is_ascii_alphabetic() && char != '\'' {
return;
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this down to avoid checking all characters of the first word if the character is uppercase anyway.

@MichaReiser MichaReiser marked this pull request as ready for review April 4, 2024 16:27
@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D403 does not trigger for a single-word docstring that ends with a period

2 participants