From d170388b7b6501946ffb4e2fb6f5ae0c80ab82bf Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 14 Nov 2022 13:07:27 -0500 Subject: [PATCH] Allow second line as 'first line' for punctuation (#741) --- src/pydocstyle/plugins.rs | 4 ++-- .../ruff__linter__tests__D400_D.py.snap | 24 ------------------- .../ruff__linter__tests__D415_D.py.snap | 24 ------------------- 3 files changed, 2 insertions(+), 50 deletions(-) diff --git a/src/pydocstyle/plugins.rs b/src/pydocstyle/plugins.rs index 6c33564932..9c7e59af9c 100644 --- a/src/pydocstyle/plugins.rs +++ b/src/pydocstyle/plugins.rs @@ -697,7 +697,7 @@ pub fn ends_with_period(checker: &mut Checker, definition: &Definition) { .. } = &docstring.node { - if let Some(string) = string.lines().next() { + if let Some(string) = string.trim().lines().next() { if !string.ends_with('.') { checker.add_check(Check::new( CheckKind::EndsInPeriod, @@ -807,7 +807,7 @@ pub fn ends_with_punctuation(checker: &mut Checker, definition: &Definition) { .. } = &docstring.node { - if let Some(string) = string.lines().next() { + if let Some(string) = string.trim().lines().next() { if !(string.ends_with('.') || string.ends_with('!') || string.ends_with('?')) { checker.add_check(Check::new( CheckKind::EndsInPunctuation, diff --git a/src/snapshots/ruff__linter__tests__D400_D.py.snap b/src/snapshots/ruff__linter__tests__D400_D.py.snap index 0f71041f6d..10ae01e5cc 100644 --- a/src/snapshots/ruff__linter__tests__D400_D.py.snap +++ b/src/snapshots/ruff__linter__tests__D400_D.py.snap @@ -2,30 +2,6 @@ source: src/linter.rs expression: checks --- -- kind: EndsInPeriod - location: - row: 124 - column: 4 - end_location: - row: 126 - column: 7 - fix: ~ -- kind: EndsInPeriod - location: - row: 283 - column: 4 - end_location: - row: 283 - column: 33 - fix: ~ -- kind: EndsInPeriod - location: - row: 288 - column: 4 - end_location: - row: 288 - column: 37 - fix: ~ - kind: EndsInPeriod location: row: 350 diff --git a/src/snapshots/ruff__linter__tests__D415_D.py.snap b/src/snapshots/ruff__linter__tests__D415_D.py.snap index 4500a8707d..814506fe28 100644 --- a/src/snapshots/ruff__linter__tests__D415_D.py.snap +++ b/src/snapshots/ruff__linter__tests__D415_D.py.snap @@ -2,30 +2,6 @@ source: src/linter.rs expression: checks --- -- kind: EndsInPunctuation - location: - row: 124 - column: 4 - end_location: - row: 126 - column: 7 - fix: ~ -- kind: EndsInPunctuation - location: - row: 283 - column: 4 - end_location: - row: 283 - column: 33 - fix: ~ -- kind: EndsInPunctuation - location: - row: 288 - column: 4 - end_location: - row: 288 - column: 37 - fix: ~ - kind: EndsInPunctuation location: row: 350