mirror of https://github.com/astral-sh/ruff
Treat whitespace-only line as blank for D411 (#7351)
This better aligns with the definition of "blank line" that we use throughout the docstring rules. Closes https://github.com/astral-sh/ruff/issues/7216.
This commit is contained in:
parent
4f26002dd5
commit
f0f7ea7502
|
|
@ -529,3 +529,16 @@ def replace_equals_with_dash2():
|
||||||
Parameters
|
Parameters
|
||||||
===========
|
===========
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@expect(_D213)
|
||||||
|
def non_empty_blank_line_before_section(): # noqa: D416
|
||||||
|
"""Toggle the gizmo.
|
||||||
|
|
||||||
|
The function's description.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
A value of some sort.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1691,7 +1691,10 @@ fn common_section(
|
||||||
}
|
}
|
||||||
|
|
||||||
if checker.enabled(Rule::NoBlankLineBeforeSection) {
|
if checker.enabled(Rule::NoBlankLineBeforeSection) {
|
||||||
if !context.previous_line().is_some_and(str::is_empty) {
|
if !context
|
||||||
|
.previous_line()
|
||||||
|
.is_some_and(|line| line.trim().is_empty())
|
||||||
|
{
|
||||||
let mut diagnostic = Diagnostic::new(
|
let mut diagnostic = Diagnostic::new(
|
||||||
NoBlankLineBeforeSection {
|
NoBlankLineBeforeSection {
|
||||||
name: context.section_name().to_string(),
|
name: context.section_name().to_string(),
|
||||||
|
|
|
||||||
|
|
@ -496,5 +496,6 @@ sections.py:527:5: D407 [*] Missing dashed underline after section ("Parameters"
|
||||||
530 |+ ----------
|
530 |+ ----------
|
||||||
530 531 | ===========
|
530 531 | ===========
|
||||||
531 532 | """
|
531 532 | """
|
||||||
|
532 533 |
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue