mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
Ignore underlines when determining docstring logical lines (#8929)
This commit is contained in:
parent
20782ab02c
commit
d674e7946d
3 changed files with 36 additions and 2 deletions
|
@ -91,3 +91,12 @@ def f(rounds: list[int], number: int) -> bool:
|
||||||
bool: was the round played?
|
bool: was the round played?
|
||||||
"""
|
"""
|
||||||
return number in rounds
|
return number in rounds
|
||||||
|
|
||||||
|
|
||||||
|
def f():
|
||||||
|
"""
|
||||||
|
My example
|
||||||
|
==========
|
||||||
|
|
||||||
|
My example explanation
|
||||||
|
"""
|
||||||
|
|
|
@ -10,8 +10,9 @@ pub(super) fn logical_line(content: &str) -> Option<usize> {
|
||||||
// Find the first logical line.
|
// Find the first logical line.
|
||||||
let mut logical_line = None;
|
let mut logical_line = None;
|
||||||
for (i, line) in content.universal_newlines().enumerate() {
|
for (i, line) in content.universal_newlines().enumerate() {
|
||||||
if line.trim().is_empty() {
|
let trimmed = line.trim();
|
||||||
// Empty line. If this is the line _after_ the first logical line, stop.
|
if trimmed.is_empty() || trimmed.chars().all(|c| matches!(c, '-' | '~' | '=' | '#')) {
|
||||||
|
// Empty line, or underline. If this is the line _after_ the first logical line, stop.
|
||||||
if logical_line.is_some() {
|
if logical_line.is_some() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,4 +247,28 @@ D400.py:69:5: D400 [*] First line should end with a period
|
||||||
73 73 |
|
73 73 |
|
||||||
74 74 |
|
74 74 |
|
||||||
|
|
||||||
|
D400.py:97:5: D400 [*] First line should end with a period
|
||||||
|
|
|
||||||
|
96 | def f():
|
||||||
|
97 | """
|
||||||
|
| _____^
|
||||||
|
98 | | My example
|
||||||
|
99 | | ==========
|
||||||
|
100 | |
|
||||||
|
101 | | My example explanation
|
||||||
|
102 | | """
|
||||||
|
| |_______^ D400
|
||||||
|
|
|
||||||
|
= help: Add period
|
||||||
|
|
||||||
|
ℹ Unsafe fix
|
||||||
|
95 95 |
|
||||||
|
96 96 | def f():
|
||||||
|
97 97 | """
|
||||||
|
98 |- My example
|
||||||
|
98 |+ My example.
|
||||||
|
99 99 | ==========
|
||||||
|
100 100 |
|
||||||
|
101 101 | My example explanation
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue