Skip to content

Commit

Permalink
add test to D40
Browse files Browse the repository at this point in the history
  • Loading branch information
yahayaohinoyi committed Sep 18, 2024
1 parent 0f68566 commit b095a33
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def f():
"""Here's a line without a period"""
...

def f():
"""Here's a line with an exclamation;"""
...

def f():
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub(crate) fn ends_with_period(checker: &mut Checker, docstring: &Docstring) {
if !trimmed.ends_with('.') {
let mut diagnostic = Diagnostic::new(EndsInPeriod, docstring.range());
// Best-effort fix: avoid adding a period after other punctuation marks.
if !trimmed.ends_with([':', ';', '?']) {
if !trimmed.ends_with([':', ';', '?', '!']) {
diagnostic.set_fix(Fix::unsafe_edit(Edit::insertion(
".".to_string(),
line.start() + trimmed.text_len(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub(crate) fn ends_with_punctuation(checker: &mut Checker, docstring: &Docstring
if !trimmed.ends_with(['.', '!', '?']) {
let mut diagnostic = Diagnostic::new(EndsInPunctuation, docstring.range());
// Best-effort fix: avoid adding a period after other punctuation marks.
if !trimmed.ends_with([':', ';', '?']) {
if !trimmed.ends_with([':', ';', '?', '!']) {
diagnostic.set_fix(Fix::unsafe_edit(Edit::insertion(
".".to_string(),
line.start() + trimmed.text_len(),
Expand Down

0 comments on commit b095a33

Please # to comment.