Skip to content

Commit

Permalink
Avoid D403 if first char cannot be uppercased (#4283)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed May 8, 2023
1 parent cd41de2 commit 4ac5065
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/ruff/resources/test/fixtures/pydocstyle/D403.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ def another_function():

def utf8_function():
"""éste docstring is capitalized."""

def uppercase_char_not_possible():
"""'args' is not capitalized."""
9 changes: 9 additions & 0 deletions crates/ruff/src/rules/pydocstyle/rules/capitalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ pub fn capitalized(checker: &mut Checker, docstring: &Docstring) {
if first_char.is_uppercase() {
return;
};
if first_char
.to_uppercase()
.next()
.map_or(false, |uppercase_first_char| {
uppercase_first_char == first_char
})
{
return;
}

let capitalized_word = first_char.to_uppercase().to_string() + first_word_chars.as_str();

Expand Down

0 comments on commit 4ac5065

Please sign in to comment.