From 202fe4ba7e2d85529216183cddd6a19ae1fb1b58 Mon Sep 17 00:00:00 2001 From: yahayaohinoyi Date: Wed, 18 Sep 2024 23:23:21 +0100 Subject: [PATCH] fix --- crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py | 3 +++ .../ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs | 2 +- .../src/rules/pydocstyle/rules/ends_with_punctuation.rs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py index 3c6cc5bfce7b1c..fab798247dcef2 100644 --- a/crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py +++ b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py @@ -7,6 +7,9 @@ def f(): """Here's a line without a period""" ... +def f(): + """Here's a line with an question mark ?""" + ... def f(): """ diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs index 1dd25dd75f5c6b..83ee5aea454f41 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs @@ -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(), diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs index 75638c119ebc47..21f7fe3a2cd90b 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs @@ -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(),