Skip to content

Commit

Permalink
Remove all trailing punctuation
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Apr 5, 2024
1 parent ff905f1 commit b91593c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ pub(crate) fn capitalized(checker: &mut Checker, docstring: &Docstring) {
}

let body = docstring.body();
let first_word = body
.split_once(' ')
.map_or_else(|| body.trim_end_matches('.'), |(first_word, _)| first_word);
let first_word = body.split_once(' ').map_or_else(
|| {
// If the docstring is a single word, trim the punctuation marks because
// it makes the ASCII test below fail.
body.trim_end_matches(['.', '!', '?'])
},
|(first_word, _)| first_word,
);

let mut first_word_chars = first_word.chars();
let Some(first_char) = first_word_chars.next() else {
Expand Down

0 comments on commit b91593c

Please sign in to comment.