forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…h#15082) ## Summary This PR fixes an issue where Ruff's `D403` rule (`first-word-uncapitalized`) was not detecting some single-word edge cases that are picked up by `pydocstyle`. The change involves extracting the first word of the docstring by identifying the first whitespace character. This is consistent with `pydocstyle` which uses `.split()` - see https://github.com/PyCQA/pydocstyle/blob/8d0cdfc93e86e096bb5753f07dc5c7c373e63837/src/pydocstyle/checker.py#L581C13-L581C64 ## Example Here is a playground example - https://play.ruff.rs/eab9ea59-92cf-4e44-b1a9-b54b7f69b178 ```py def example1(): """foo""" def example2(): """foo Hello world! """ def example3(): """foo bar Hello world! """ def example4(): """ foo """ def example5(): """ foo bar """ ``` `pydocstyle` detects all five cases: ```bash $ pydocstyle test.py --select D403 dev/test.py:2 in public function `example1`: D403: First word of the first line should be properly capitalized ('Foo', not 'foo') dev/test.py:5 in public function `example2`: D403: First word of the first line should be properly capitalized ('Foo', not 'foo') dev/test.py:11 in public function `example3`: D403: First word of the first line should be properly capitalized ('Foo', not 'foo') dev/test.py:17 in public function `example4`: D403: First word of the first line should be properly capitalized ('Foo', not 'foo') dev/test.py:22 in public function `example5`: D403: First word of the first line should be properly capitalized ('Foo', not 'foo') ``` Ruff (`0.8.4`) fails to catch example2 and example4. ## Test Plan * Added two new test cases to cover the previously missed single-word docstring cases.
- Loading branch information
Showing
3 changed files
with
241 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters