From 85302d5d91697b1e9eb21dc5c9d15d013acd22bf Mon Sep 17 00:00:00 2001 From: Hoel Bagard Date: Tue, 6 Feb 2024 20:28:05 +0900 Subject: [PATCH] add wrongly indented comment test --- .../test/fixtures/pycodestyle/E30.py | 24 ++ ...ules__pycodestyle__tests__E301_E30.py.snap | 52 +-- ...ules__pycodestyle__tests__E302_E30.py.snap | 250 +++++++------- ...ules__pycodestyle__tests__E303_E30.py.snap | 254 +++++++------- ...ules__pycodestyle__tests__E304_E30.py.snap | 80 ++--- ...ules__pycodestyle__tests__E305_E30.py.snap | 126 +++---- ...ules__pycodestyle__tests__E306_E30.py.snap | 324 +++++++++--------- 7 files changed, 576 insertions(+), 534 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py index 82d8f47db9466..37c2e6d803ce7 100644 --- a/crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py +++ b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py @@ -425,6 +425,17 @@ def a(self): pass # end +# no error +class Test: + def a(): + pass +# wrongly indented comment + + def b(): + pass +# end + + # E301 class Class(object): @@ -624,6 +635,19 @@ def test(self): pass # end +# E303 +class Test: + def a(self): + pass + +# wrongly indented comment + + + def b(self): + pass +# end + + # E304 @decorator diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap index a286249e86784..5e3e0713fc108 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap @@ -1,44 +1,44 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:433:5: E301 [*] Expected 1 blank line, found 0 +E30.py:444:5: E301 [*] Expected 1 blank line, found 0 | -431 | def func1(): -432 | pass -433 | def func2(): +442 | def func1(): +443 | pass +444 | def func2(): | ^^^ E301 -434 | pass -435 | # end +445 | pass +446 | # end | = help: Add missing blank line(s) ℹ Safe fix -430 430 | -431 431 | def func1(): -432 432 | pass - 433 |+ -433 434 | def func2(): -434 435 | pass -435 436 | # end +441 441 | +442 442 | def func1(): +443 443 | pass + 444 |+ +444 445 | def func2(): +445 446 | pass +446 447 | # end -E30.py:444:5: E301 [*] Expected 1 blank line, found 0 +E30.py:455:5: E301 [*] Expected 1 blank line, found 0 | -442 | pass -443 | # comment -444 | def fn2(): +453 | pass +454 | # comment +455 | def fn2(): | ^^^ E301 -445 | pass -446 | # end +456 | pass +457 | # end | = help: Add missing blank line(s) ℹ Safe fix -440 440 | -441 441 | def fn1(): -442 442 | pass - 443 |+ -443 444 | # comment -444 445 | def fn2(): -445 446 | pass +451 451 | +452 452 | def fn1(): +453 453 | pass + 454 |+ +454 455 | # comment +455 456 | def fn2(): +456 457 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap index a6a4fb871af5f..24311cccff3ed 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap @@ -1,71 +1,51 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:451:1: E302 [*] Expected 2 blank lines, found 0 +E30.py:462:1: E302 [*] Expected 2 blank lines, found 0 | -449 | # E302 -450 | """Main module.""" -451 | def fn(): +460 | # E302 +461 | """Main module.""" +462 | def fn(): | ^^^ E302 -452 | pass -453 | # end +463 | pass +464 | # end | = help: Add missing blank line(s) ℹ Safe fix -448 448 | -449 449 | # E302 -450 450 | """Main module.""" - 451 |+ - 452 |+ -451 453 | def fn(): -452 454 | pass -453 455 | # end - -E30.py:458:1: E302 [*] Expected 2 blank lines, found 0 - | -456 | # E302 -457 | import sys -458 | def get_sys_path(): +459 459 | +460 460 | # E302 +461 461 | """Main module.""" + 462 |+ + 463 |+ +462 464 | def fn(): +463 465 | pass +464 466 | # end + +E30.py:469:1: E302 [*] Expected 2 blank lines, found 0 + | +467 | # E302 +468 | import sys +469 | def get_sys_path(): | ^^^ E302 -459 | return sys.path -460 | # end +470 | return sys.path +471 | # end | = help: Add missing blank line(s) ℹ Safe fix -455 455 | -456 456 | # E302 -457 457 | import sys - 458 |+ - 459 |+ -458 460 | def get_sys_path(): -459 461 | return sys.path -460 462 | # end - -E30.py:467:1: E302 [*] Expected 2 blank lines, found 1 - | -465 | pass -466 | -467 | def b(): - | ^^^ E302 -468 | pass -469 | # end - | - = help: Add missing blank line(s) - -ℹ Safe fix -464 464 | def a(): -465 465 | pass 466 466 | - 467 |+ -467 468 | def b(): -468 469 | pass -469 470 | # end +467 467 | # E302 +468 468 | import sys + 469 |+ + 470 |+ +469 471 | def get_sys_path(): +470 472 | return sys.path +471 473 | # end E30.py:478:1: E302 [*] Expected 2 blank lines, found 1 | -476 | # comment +476 | pass 477 | 478 | def b(): | ^^^ E302 @@ -75,113 +55,133 @@ E30.py:478:1: E302 [*] Expected 2 blank lines, found 1 = help: Add missing blank line(s) ℹ Safe fix -475 475 | -476 476 | # comment +475 475 | def a(): +476 476 | pass 477 477 | 478 |+ 478 479 | def b(): 479 480 | pass 480 481 | # end -E30.py:487:1: E302 [*] Expected 2 blank lines, found 1 +E30.py:489:1: E302 [*] Expected 2 blank lines, found 1 | -485 | pass -486 | -487 | async def b(): - | ^^^^^ E302 -488 | pass -489 | # end +487 | # comment +488 | +489 | def b(): + | ^^^ E302 +490 | pass +491 | # end | = help: Add missing blank line(s) ℹ Safe fix -484 484 | def a(): -485 485 | pass 486 486 | - 487 |+ -487 488 | async def b(): -488 489 | pass -489 490 | # end - -E30.py:496:1: E302 [*] Expected 2 blank lines, found 1 +487 487 | # comment +488 488 | + 489 |+ +489 490 | def b(): +490 491 | pass +491 492 | # end + +E30.py:498:1: E302 [*] Expected 2 blank lines, found 1 + | +496 | pass +497 | +498 | async def b(): + | ^^^^^ E302 +499 | pass +500 | # end | -494 | pass -495 | -496 | async def x(y: int = 1): + = help: Add missing blank line(s) + +ℹ Safe fix +495 495 | def a(): +496 496 | pass +497 497 | + 498 |+ +498 499 | async def b(): +499 500 | pass +500 501 | # end + +E30.py:507:1: E302 [*] Expected 2 blank lines, found 1 + | +505 | pass +506 | +507 | async def x(y: int = 1): | ^^^^^ E302 -497 | pass -498 | # end +508 | pass +509 | # end | = help: Add missing blank line(s) ℹ Safe fix -493 493 | async def x(): -494 494 | pass -495 495 | - 496 |+ -496 497 | async def x(y: int = 1): -497 498 | pass -498 499 | # end - -E30.py:504:1: E302 [*] Expected 2 blank lines, found 0 - | -502 | def bar(): -503 | pass -504 | def baz(): pass +504 504 | async def x(): +505 505 | pass +506 506 | + 507 |+ +507 508 | async def x(y: int = 1): +508 509 | pass +509 510 | # end + +E30.py:515:1: E302 [*] Expected 2 blank lines, found 0 + | +513 | def bar(): +514 | pass +515 | def baz(): pass | ^^^ E302 -505 | # end +516 | # end | = help: Add missing blank line(s) ℹ Safe fix -501 501 | # E302 -502 502 | def bar(): -503 503 | pass - 504 |+ - 505 |+ -504 506 | def baz(): pass -505 507 | # end -506 508 | - -E30.py:510:1: E302 [*] Expected 2 blank lines, found 0 - | -508 | # E302 -509 | def bar(): pass -510 | def baz(): +512 512 | # E302 +513 513 | def bar(): +514 514 | pass + 515 |+ + 516 |+ +515 517 | def baz(): pass +516 518 | # end +517 519 | + +E30.py:521:1: E302 [*] Expected 2 blank lines, found 0 + | +519 | # E302 +520 | def bar(): pass +521 | def baz(): | ^^^ E302 -511 | pass -512 | # end +522 | pass +523 | # end | = help: Add missing blank line(s) ℹ Safe fix -507 507 | -508 508 | # E302 -509 509 | def bar(): pass - 510 |+ - 511 |+ -510 512 | def baz(): -511 513 | pass -512 514 | # end - -E30.py:520:1: E302 [*] Expected 2 blank lines, found 1 - | -519 | # comment -520 | @decorator +518 518 | +519 519 | # E302 +520 520 | def bar(): pass + 521 |+ + 522 |+ +521 523 | def baz(): +522 524 | pass +523 525 | # end + +E30.py:531:1: E302 [*] Expected 2 blank lines, found 1 + | +530 | # comment +531 | @decorator | ^ E302 -521 | def g(): -522 | pass +532 | def g(): +533 | pass | = help: Add missing blank line(s) ℹ Safe fix -516 516 | def f(): -517 517 | pass -518 518 | - 519 |+ - 520 |+ -519 521 | # comment -520 522 | @decorator -521 523 | def g(): +527 527 | def f(): +528 528 | pass +529 529 | + 530 |+ + 531 |+ +530 532 | # comment +531 533 | @decorator +532 534 | def g(): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap index 58beadf153d8c..e6d6555838263 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap @@ -1,197 +1,215 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:531:5: E303 [*] Too many blank lines (2) +E30.py:542:5: E303 [*] Too many blank lines (2) | -531 | # arbitrary comment +542 | # arbitrary comment | ^^^^^^^^^^^^^^^^^^^ E303 -532 | -533 | def inner(): # E306 not expected (pycodestyle detects E306) +543 | +544 | def inner(): # E306 not expected (pycodestyle detects E306) | = help: Remove extraneous blank line(s) ℹ Safe fix -527 527 | def fn(): -528 528 | _ = None -529 529 | -530 |- -531 530 | # arbitrary comment -532 531 | -533 532 | def inner(): # E306 not expected (pycodestyle detects E306) +538 538 | def fn(): +539 539 | _ = None +540 540 | +541 |- +542 541 | # arbitrary comment +543 542 | +544 543 | def inner(): # E306 not expected (pycodestyle detects E306) -E30.py:543:5: E303 [*] Too many blank lines (2) +E30.py:554:5: E303 [*] Too many blank lines (2) | -543 | # arbitrary comment +554 | # arbitrary comment | ^^^^^^^^^^^^^^^^^^^ E303 -544 | def inner(): # E306 not expected (pycodestyle detects E306) -545 | pass +555 | def inner(): # E306 not expected (pycodestyle detects E306) +556 | pass | = help: Remove extraneous blank line(s) ℹ Safe fix -539 539 | def fn(): -540 540 | _ = None -541 541 | -542 |- -543 542 | # arbitrary comment -544 543 | def inner(): # E306 not expected (pycodestyle detects E306) -545 544 | pass +550 550 | def fn(): +551 551 | _ = None +552 552 | +553 |- +554 553 | # arbitrary comment +555 554 | def inner(): # E306 not expected (pycodestyle detects E306) +556 555 | pass -E30.py:554:1: E303 [*] Too many blank lines (3) +E30.py:565:1: E303 [*] Too many blank lines (3) | -554 | print() +565 | print() | ^^^^^ E303 -555 | # end +566 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -550 550 | print() -551 551 | -552 552 | -553 |- -554 553 | print() -555 554 | # end -556 555 | +561 561 | print() +562 562 | +563 563 | +564 |- +565 564 | print() +566 565 | # end +567 566 | -E30.py:563:1: E303 [*] Too many blank lines (3) +E30.py:574:1: E303 [*] Too many blank lines (3) | -563 | # comment +574 | # comment | ^^^^^^^^^ E303 -564 | -565 | print() +575 | +576 | print() | = help: Remove extraneous blank line(s) ℹ Safe fix -559 559 | print() -560 560 | -561 561 | -562 |- -563 562 | # comment -564 563 | -565 564 | print() +570 570 | print() +571 571 | +572 572 | +573 |- +574 573 | # comment +575 574 | +576 575 | print() -E30.py:574:5: E303 [*] Too many blank lines (2) +E30.py:585:5: E303 [*] Too many blank lines (2) | -574 | # comment +585 | # comment | ^^^^^^^^^ E303 | = help: Remove extraneous blank line(s) ℹ Safe fix -570 570 | def a(): -571 571 | print() -572 572 | -573 |- -574 573 | # comment -575 574 | -576 575 | +581 581 | def a(): +582 582 | print() +583 583 | +584 |- +585 584 | # comment +586 585 | +587 586 | -E30.py:577:5: E303 [*] Too many blank lines (2) +E30.py:588:5: E303 [*] Too many blank lines (2) | -577 | # another comment +588 | # another comment | ^^^^^^^^^^^^^^^^^ E303 -578 | -579 | print() +589 | +590 | print() | = help: Remove extraneous blank line(s) ℹ Safe fix -573 573 | -574 574 | # comment -575 575 | -576 |- -577 576 | # another comment -578 577 | -579 578 | print() - -E30.py:588:1: E303 [*] Too many blank lines (3) - | -588 | / """This class docstring comes on line 5. -589 | | It gives error E303: too many blank lines (3) -590 | | """ +584 584 | +585 585 | # comment +586 586 | +587 |- +588 587 | # another comment +589 588 | +590 589 | print() + +E30.py:599:1: E303 [*] Too many blank lines (3) + | +599 | / """This class docstring comes on line 5. +600 | | It gives error E303: too many blank lines (3) +601 | | """ | |___^ E303 -591 | # end +602 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -584 584 | #!python -585 585 | -586 586 | -587 |- -588 587 | """This class docstring comes on line 5. -589 588 | It gives error E303: too many blank lines (3) -590 589 | """ +595 595 | #!python +596 596 | +597 597 | +598 |- +599 598 | """This class docstring comes on line 5. +600 599 | It gives error E303: too many blank lines (3) +601 600 | """ -E30.py:600:5: E303 [*] Too many blank lines (2) +E30.py:611:5: E303 [*] Too many blank lines (2) | -600 | def b(self): +611 | def b(self): | ^^^ E303 -601 | pass -602 | # end +612 | pass +613 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -596 596 | def a(self): -597 597 | pass -598 598 | -599 |- -600 599 | def b(self): -601 600 | pass -602 601 | # end +607 607 | def a(self): +608 608 | pass +609 609 | +610 |- +611 610 | def b(self): +612 611 | pass +613 612 | # end -E30.py:610:5: E303 [*] Too many blank lines (2) +E30.py:621:5: E303 [*] Too many blank lines (2) | -610 | a = 2 +621 | a = 2 | ^ E303 -611 | # end +622 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -606 606 | if True: -607 607 | a = 1 -608 608 | -609 |- -610 609 | a = 2 -611 610 | # end -612 611 | +617 617 | if True: +618 618 | a = 1 +619 619 | +620 |- +621 620 | a = 2 +622 621 | # end +623 622 | -E30.py:618:5: E303 [*] Too many blank lines (2) +E30.py:629:5: E303 [*] Too many blank lines (2) | -618 | # comment +629 | # comment | ^^^^^^^^^ E303 | = help: Remove extraneous blank line(s) ℹ Safe fix -614 614 | # E303 -615 615 | class Test: -616 616 | -617 |- -618 617 | # comment -619 618 | -620 619 | +625 625 | # E303 +626 626 | class Test: +627 627 | +628 |- +629 628 | # comment +630 629 | +631 630 | -E30.py:621:5: E303 [*] Too many blank lines (2) +E30.py:632:5: E303 [*] Too many blank lines (2) | -621 | # another comment +632 | # another comment | ^^^^^^^^^^^^^^^^^ E303 -622 | -623 | def test(self): pass +633 | +634 | def test(self): pass | = help: Remove extraneous blank line(s) ℹ Safe fix -617 617 | -618 618 | # comment -619 619 | -620 |- -621 620 | # another comment -622 621 | -623 622 | def test(self): pass +628 628 | +629 629 | # comment +630 630 | +631 |- +632 631 | # another comment +633 632 | +634 633 | def test(self): pass + +E30.py:646:5: E303 [*] Too many blank lines (2) + | +646 | def b(self): + | ^^^ E303 +647 | pass +648 | # end + | + = help: Remove extraneous blank line(s) + +ℹ Safe fix +642 642 | +643 643 | # wrongly indented comment +644 644 | +645 |- +646 645 | def b(self): +647 646 | pass +648 647 | # end diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap index 60b9a67b3e9a5..2c320bae8996f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap @@ -1,65 +1,65 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:630:1: E304 [*] blank lines found after function decorator +E30.py:654:1: E304 [*] blank lines found after function decorator | -628 | @decorator -629 | -630 | def function(): +652 | @decorator +653 | +654 | def function(): | ^^^ E304 -631 | pass -632 | # end +655 | pass +656 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -626 626 | -627 627 | # E304 -628 628 | @decorator -629 |- -630 629 | def function(): -631 630 | pass -632 631 | # end +650 650 | +651 651 | # E304 +652 652 | @decorator +653 |- +654 653 | def function(): +655 654 | pass +656 655 | # end -E30.py:639:1: E304 [*] blank lines found after function decorator +E30.py:663:1: E304 [*] blank lines found after function decorator | -638 | # comment E304 not expected -639 | def function(): +662 | # comment E304 not expected +663 | def function(): | ^^^ E304 -640 | pass -641 | # end +664 | pass +665 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -634 634 | -635 635 | # E304 -636 636 | @decorator -637 |- -638 637 | # comment E304 not expected -639 638 | def function(): -640 639 | pass +658 658 | +659 659 | # E304 +660 660 | @decorator +661 |- +662 661 | # comment E304 not expected +663 662 | def function(): +664 663 | pass -E30.py:651:1: E304 [*] blank lines found after function decorator +E30.py:675:1: E304 [*] blank lines found after function decorator | -650 | # second comment E304 not expected -651 | def function(): +674 | # second comment E304 not expected +675 | def function(): | ^^^ E304 -652 | pass -653 | # end +676 | pass +677 | # end | = help: Remove extraneous blank line(s) ℹ Safe fix -643 643 | -644 644 | # E304 -645 645 | @decorator -646 |- -647 646 | # comment E304 not expected -648 |- -649 |- -650 647 | # second comment E304 not expected -651 648 | def function(): -652 649 | pass +667 667 | +668 668 | # E304 +669 669 | @decorator +670 |- +671 670 | # comment E304 not expected +672 |- +673 |- +674 671 | # second comment E304 not expected +675 672 | def function(): +676 673 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap index 0981e4406115f..987bcb885f97b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap @@ -1,102 +1,102 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:663:1: E305 [*] expected 2 blank lines after class or function definition, found (1) +E30.py:687:1: E305 [*] expected 2 blank lines after class or function definition, found (1) | -662 | # another comment -663 | fn() +686 | # another comment +687 | fn() | ^^ E305 -664 | # end +688 | # end | = help: Add missing blank line(s) ℹ Safe fix -660 660 | # comment -661 661 | -662 662 | # another comment - 663 |+ - 664 |+ -663 665 | fn() -664 666 | # end -665 667 | +684 684 | # comment +685 685 | +686 686 | # another comment + 687 |+ + 688 |+ +687 689 | fn() +688 690 | # end +689 691 | -E30.py:674:1: E305 [*] expected 2 blank lines after class or function definition, found (1) +E30.py:698:1: E305 [*] expected 2 blank lines after class or function definition, found (1) | -673 | # another comment -674 | a = 1 +697 | # another comment +698 | a = 1 | ^ E305 -675 | # end +699 | # end | = help: Add missing blank line(s) ℹ Safe fix -671 671 | # comment -672 672 | -673 673 | # another comment - 674 |+ - 675 |+ -674 676 | a = 1 -675 677 | # end -676 678 | +695 695 | # comment +696 696 | +697 697 | # another comment + 698 |+ + 699 |+ +698 700 | a = 1 +699 701 | # end +700 702 | -E30.py:686:1: E305 [*] expected 2 blank lines after class or function definition, found (1) +E30.py:710:1: E305 [*] expected 2 blank lines after class or function definition, found (1) | -684 | # another comment -685 | -686 | try: +708 | # another comment +709 | +710 | try: | ^^^ E305 -687 | fn() -688 | except Exception: +711 | fn() +712 | except Exception: | = help: Add missing blank line(s) ℹ Safe fix -683 683 | -684 684 | # another comment -685 685 | - 686 |+ -686 687 | try: -687 688 | fn() -688 689 | except Exception: +707 707 | +708 708 | # another comment +709 709 | + 710 |+ +710 711 | try: +711 712 | fn() +712 713 | except Exception: -E30.py:698:1: E305 [*] expected 2 blank lines after class or function definition, found (1) +E30.py:722:1: E305 [*] expected 2 blank lines after class or function definition, found (1) | -697 | # Two spaces before comments, too. -698 | if a(): +721 | # Two spaces before comments, too. +722 | if a(): | ^^ E305 -699 | a() -700 | # end +723 | a() +724 | # end | = help: Add missing blank line(s) ℹ Safe fix -695 695 | print() -696 696 | -697 697 | # Two spaces before comments, too. - 698 |+ - 699 |+ -698 700 | if a(): -699 701 | a() -700 702 | # end +719 719 | print() +720 720 | +721 721 | # Two spaces before comments, too. + 722 |+ + 723 |+ +722 724 | if a(): +723 725 | a() +724 726 | # end -E30.py:711:1: E305 [*] expected 2 blank lines after class or function definition, found (1) +E30.py:735:1: E305 [*] expected 2 blank lines after class or function definition, found (1) | -709 | blah, blah -710 | -711 | if __name__ == '__main__': +733 | blah, blah +734 | +735 | if __name__ == '__main__': | ^^ E305 -712 | main() -713 | # end +736 | main() +737 | # end | = help: Add missing blank line(s) ℹ Safe fix -708 708 | def main(): -709 709 | blah, blah -710 710 | - 711 |+ -711 712 | if __name__ == '__main__': -712 713 | main() -713 714 | # end +732 732 | def main(): +733 733 | blah, blah +734 734 | + 735 |+ +735 736 | if __name__ == '__main__': +736 737 | main() +737 738 | # end diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap index 1026bc1ea8d2b..c9a2629b06795 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap @@ -1,223 +1,223 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:719:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E30.py:743:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | -717 | def a(): -718 | x = 1 -719 | def b(): +741 | def a(): +742 | x = 1 +743 | def b(): | ^^^ E306 -720 | pass -721 | # end +744 | pass +745 | # end | = help: Add missing blank line ℹ Safe fix -716 716 | # E306:3:5 -717 717 | def a(): -718 718 | x = 1 - 719 |+ -719 720 | def b(): -720 721 | pass -721 722 | # end - -E30.py:727:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -725 | async def a(): -726 | x = 1 -727 | def b(): +740 740 | # E306:3:5 +741 741 | def a(): +742 742 | x = 1 + 743 |+ +743 744 | def b(): +744 745 | pass +745 746 | # end + +E30.py:751:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +749 | async def a(): +750 | x = 1 +751 | def b(): | ^^^ E306 -728 | pass -729 | # end +752 | pass +753 | # end | = help: Add missing blank line ℹ Safe fix -724 724 | #: E306:3:5 -725 725 | async def a(): -726 726 | x = 1 - 727 |+ -727 728 | def b(): -728 729 | pass -729 730 | # end - -E30.py:735:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -733 | def a(): -734 | x = 2 -735 | def b(): +748 748 | #: E306:3:5 +749 749 | async def a(): +750 750 | x = 1 + 751 |+ +751 752 | def b(): +752 753 | pass +753 754 | # end + +E30.py:759:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +757 | def a(): +758 | x = 2 +759 | def b(): | ^^^ E306 -736 | x = 1 -737 | def c(): +760 | x = 1 +761 | def c(): | = help: Add missing blank line ℹ Safe fix -732 732 | #: E306:3:5 E306:5:9 -733 733 | def a(): -734 734 | x = 2 - 735 |+ -735 736 | def b(): -736 737 | x = 1 -737 738 | def c(): - -E30.py:737:9: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -735 | def b(): -736 | x = 1 -737 | def c(): +756 756 | #: E306:3:5 E306:5:9 +757 757 | def a(): +758 758 | x = 2 + 759 |+ +759 760 | def b(): +760 761 | x = 1 +761 762 | def c(): + +E30.py:761:9: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +759 | def b(): +760 | x = 1 +761 | def c(): | ^^^ E306 -738 | pass -739 | # end +762 | pass +763 | # end | = help: Add missing blank line ℹ Safe fix -734 734 | x = 2 -735 735 | def b(): -736 736 | x = 1 - 737 |+ -737 738 | def c(): -738 739 | pass -739 740 | # end - -E30.py:745:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -743 | def a(): -744 | x = 1 -745 | class C: +758 758 | x = 2 +759 759 | def b(): +760 760 | x = 1 + 761 |+ +761 762 | def c(): +762 763 | pass +763 764 | # end + +E30.py:769:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +767 | def a(): +768 | x = 1 +769 | class C: | ^^^^^ E306 -746 | pass -747 | x = 2 +770 | pass +771 | x = 2 | = help: Add missing blank line ℹ Safe fix -742 742 | # E306:3:5 E306:6:5 -743 743 | def a(): -744 744 | x = 1 - 745 |+ -745 746 | class C: -746 747 | pass -747 748 | x = 2 - -E30.py:748:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -746 | pass -747 | x = 2 -748 | def b(): +766 766 | # E306:3:5 E306:6:5 +767 767 | def a(): +768 768 | x = 1 + 769 |+ +769 770 | class C: +770 771 | pass +771 772 | x = 2 + +E30.py:772:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +770 | pass +771 | x = 2 +772 | def b(): | ^^^ E306 -749 | pass -750 | # end +773 | pass +774 | # end | = help: Add missing blank line ℹ Safe fix -745 745 | class C: -746 746 | pass -747 747 | x = 2 - 748 |+ -748 749 | def b(): -749 750 | pass -750 751 | # end - -E30.py:757:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -755 | def bar(): -756 | pass -757 | def baz(): pass +769 769 | class C: +770 770 | pass +771 771 | x = 2 + 772 |+ +772 773 | def b(): +773 774 | pass +774 775 | # end + +E30.py:781:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +779 | def bar(): +780 | pass +781 | def baz(): pass | ^^^ E306 -758 | # end +782 | # end | = help: Add missing blank line ℹ Safe fix -754 754 | def foo(): -755 755 | def bar(): -756 756 | pass - 757 |+ -757 758 | def baz(): pass -758 759 | # end -759 760 | - -E30.py:764:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -762 | def foo(): -763 | def bar(): pass -764 | def baz(): +778 778 | def foo(): +779 779 | def bar(): +780 780 | pass + 781 |+ +781 782 | def baz(): pass +782 783 | # end +783 784 | + +E30.py:788:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +786 | def foo(): +787 | def bar(): pass +788 | def baz(): | ^^^ E306 -765 | pass -766 | # end +789 | pass +790 | # end | = help: Add missing blank line ℹ Safe fix -761 761 | # E306:3:5 -762 762 | def foo(): -763 763 | def bar(): pass - 764 |+ -764 765 | def baz(): -765 766 | pass -766 767 | # end - -E30.py:772:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -770 | def a(): -771 | x = 2 -772 | @decorator +785 785 | # E306:3:5 +786 786 | def foo(): +787 787 | def bar(): pass + 788 |+ +788 789 | def baz(): +789 790 | pass +790 791 | # end + +E30.py:796:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +794 | def a(): +795 | x = 2 +796 | @decorator | ^ E306 -773 | def b(): -774 | pass +797 | def b(): +798 | pass | = help: Add missing blank line ℹ Safe fix -769 769 | # E306 -770 770 | def a(): -771 771 | x = 2 - 772 |+ -772 773 | @decorator -773 774 | def b(): -774 775 | pass - -E30.py:781:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -779 | def a(): -780 | x = 2 -781 | @decorator +793 793 | # E306 +794 794 | def a(): +795 795 | x = 2 + 796 |+ +796 797 | @decorator +797 798 | def b(): +798 799 | pass + +E30.py:805:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +803 | def a(): +804 | x = 2 +805 | @decorator | ^ E306 -782 | async def b(): -783 | pass +806 | async def b(): +807 | pass | = help: Add missing blank line ℹ Safe fix -778 778 | # E306 -779 779 | def a(): -780 780 | x = 2 - 781 |+ -781 782 | @decorator -782 783 | async def b(): -783 784 | pass - -E30.py:790:5: E306 [*] Expected 1 blank line before a nested definition, found 0 - | -788 | def a(): -789 | x = 2 -790 | async def b(): +802 802 | # E306 +803 803 | def a(): +804 804 | x = 2 + 805 |+ +805 806 | @decorator +806 807 | async def b(): +807 808 | pass + +E30.py:814:5: E306 [*] Expected 1 blank line before a nested definition, found 0 + | +812 | def a(): +813 | x = 2 +814 | async def b(): | ^^^^^ E306 -791 | pass -792 | # end +815 | pass +816 | # end | = help: Add missing blank line ℹ Safe fix -787 787 | # E306 -788 788 | def a(): -789 789 | x = 2 - 790 |+ -790 791 | async def b(): -791 792 | pass -792 793 | # end +811 811 | # E306 +812 812 | def a(): +813 813 | x = 2 + 814 |+ +814 815 | async def b(): +815 816 | pass +816 817 | # end