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

D403: Require capitalizing single word sentence #10776

Merged
merged 2 commits into from Apr 5, 2024
Merged

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
Copy link

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.

@MichaReiser MichaReiser merged commit 2e7a1a4 into main Apr 5, 2024
17 checks passed
@MichaReiser MichaReiser deleted the d403-single-word branch April 5, 2024 06:42
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request Apr 12, 2024
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