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 ec7a11d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs
Expand Up @@ -61,7 +61,11 @@ 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);
.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 ec7a11d

Please sign in to comment.