Fix E30X panics on blank lines with trailing white spaces (#9907)

This commit is contained in:
Hoël Bagard 2024-02-09 23:00:26 +09:00 committed by GitHub
parent b4f2882b72
commit 12a91f4e90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 594 additions and 528 deletions

View file

@ -436,6 +436,15 @@ class Test:
# end # end
# no error
def test():
pass
# Wrongly indented comment
pass
# end
# E301 # E301
class Class(object): class Class(object):
@ -534,6 +543,20 @@ def g():
# end # end
# E302
class Test:
pass
def method1():
return 1
def method2():
return 22
# end
# E303 # E303
def fn(): def fn():
_ = None _ = None
@ -648,6 +671,15 @@ class Test:
# end # end
# E303
def fn():
pass
pass
# end
# E304 # E304
@decorator @decorator

View file

@ -501,7 +501,6 @@ impl BlankLines {
} }
} }
BlankLines::Many { count, range } => { BlankLines::Many { count, range } => {
assert_eq!(range.end(), line_range.start());
*count = count.saturating_add(1); *count = count.saturating_add(1);
*range = TextRange::new(range.start(), line_range.end()); *range = TextRange::new(range.start(), line_range.end());
} }

View file

@ -1,44 +1,44 @@
--- ---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
--- ---
E30.py:444:5: E301 [*] Expected 1 blank line, found 0 E30.py:453:5: E301 [*] Expected 1 blank line, found 0
| |
442 | def func1(): 451 | def func1():
443 | pass 452 | pass
444 | def func2(): 453 | def func2():
| ^^^ E301 | ^^^ E301
445 | pass 454 | pass
446 | # end 455 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
441 441 | 450 450 |
442 442 | def func1(): 451 451 | def func1():
443 443 | pass 452 452 | pass
444 |+ 453 |+
444 445 | def func2(): 453 454 | def func2():
445 446 | pass 454 455 | pass
446 447 | # end 455 456 | # end
E30.py:455:5: E301 [*] Expected 1 blank line, found 0 E30.py:464:5: E301 [*] Expected 1 blank line, found 0
| |
453 | pass 462 | pass
454 | # comment 463 | # comment
455 | def fn2(): 464 | def fn2():
| ^^^ E301 | ^^^ E301
456 | pass 465 | pass
457 | # end 466 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
451 451 | 460 460 |
452 452 | def fn1(): 461 461 | def fn1():
453 453 | pass 462 462 | pass
454 |+ 463 |+
454 455 | # comment 463 464 | # comment
455 456 | def fn2(): 464 465 | def fn2():
456 457 | pass 465 466 | pass

View file

@ -1,105 +1,85 @@
--- ---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
--- ---
E30.py:462:1: E302 [*] Expected 2 blank lines, found 0 E30.py:471:1: E302 [*] Expected 2 blank lines, found 0
| |
460 | # E302 469 | # E302
461 | """Main module.""" 470 | """Main module."""
462 | def fn(): 471 | def fn():
| ^^^ E302 | ^^^ E302
463 | pass 472 | pass
464 | # end 473 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
459 459 | 468 468 |
460 460 | # E302 469 469 | # E302
461 461 | """Main module.""" 470 470 | """Main module."""
462 |+ 471 |+
463 |+ 472 |+
462 464 | def fn(): 471 473 | def fn():
463 465 | pass 472 474 | pass
464 466 | # end 473 475 | # end
E30.py:469:1: E302 [*] Expected 2 blank lines, found 0 E30.py:478:1: E302 [*] Expected 2 blank lines, found 0
| |
467 | # E302 476 | # E302
468 | import sys 477 | import sys
469 | def get_sys_path(): 478 | def get_sys_path():
| ^^^ E302 | ^^^ E302
470 | return sys.path 479 | return sys.path
471 | # end
|
= help: Add missing blank line(s)
Safe fix
466 466 |
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 | pass
477 |
478 | def b():
| ^^^ E302
479 | pass
480 | # end 480 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
475 475 | def a(): 475 475 |
476 476 | pass 476 476 | # E302
477 477 | 477 477 | import sys
478 |+ 478 |+
478 479 | def b(): 479 |+
479 480 | pass 478 480 | def get_sys_path():
480 481 | # end 479 481 | return sys.path
480 482 | # end
E30.py:489:1: E302 [*] Expected 2 blank lines, found 1 E30.py:487:1: E302 [*] Expected 2 blank lines, found 1
| |
487 | # comment 485 | pass
488 | 486 |
489 | def b(): 487 | def b():
| ^^^ E302 | ^^^ E302
490 | pass 488 | pass
491 | # end 489 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
484 484 | def a():
485 485 | pass
486 486 | 486 486 |
487 487 | # comment 487 |+
488 488 | 487 488 | def b():
489 |+ 488 489 | pass
489 490 | def b(): 489 490 | # end
490 491 | pass
491 492 | # end
E30.py:498:1: E302 [*] Expected 2 blank lines, found 1 E30.py:498:1: E302 [*] Expected 2 blank lines, found 1
| |
496 | pass 496 | # comment
497 | 497 |
498 | async def b(): 498 | def b():
| ^^^^^ E302 | ^^^ E302
499 | pass 499 | pass
500 | # end 500 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
495 495 | def a(): 495 495 |
496 496 | pass 496 496 | # comment
497 497 | 497 497 |
498 |+ 498 |+
498 499 | async def b(): 498 499 | def b():
499 500 | pass 499 500 | pass
500 501 | # end 500 501 | # end
@ -107,7 +87,7 @@ E30.py:507:1: E302 [*] Expected 2 blank lines, found 1
| |
505 | pass 505 | pass
506 | 506 |
507 | async def x(y: int = 1): 507 | async def b():
| ^^^^^ E302 | ^^^^^ E302
508 | pass 508 | pass
509 | # end 509 | # end
@ -115,73 +95,93 @@ E30.py:507:1: E302 [*] Expected 2 blank lines, found 1
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
504 504 | async def x(): 504 504 | def a():
505 505 | pass 505 505 | pass
506 506 | 506 506 |
507 |+ 507 |+
507 508 | async def x(y: int = 1): 507 508 | async def b():
508 509 | pass 508 509 | pass
509 510 | # end 509 510 | # end
E30.py:515:1: E302 [*] Expected 2 blank lines, found 0 E30.py:516:1: E302 [*] Expected 2 blank lines, found 1
| |
513 | def bar():
514 | pass 514 | pass
515 | def baz(): pass 515 |
| ^^^ E302 516 | async def x(y: int = 1):
516 | # end | ^^^^^ E302
517 | pass
518 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
512 512 | # E302 513 513 | async def x():
513 513 | def bar():
514 514 | pass 514 514 | pass
515 |+ 515 515 |
516 |+ 516 |+
515 517 | def baz(): pass 516 517 | async def x(y: int = 1):
516 518 | # end 517 518 | pass
517 519 | 518 519 | # end
E30.py:521:1: E302 [*] Expected 2 blank lines, found 0 E30.py:524:1: E302 [*] Expected 2 blank lines, found 0
| |
519 | # E302 522 | def bar():
520 | def bar(): pass 523 | pass
521 | def baz(): 524 | def baz(): pass
| ^^^ E302 | ^^^ E302
522 | pass 525 | # end
523 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
518 518 | 521 521 | # E302
519 519 | # E302 522 522 | def bar():
520 520 | def bar(): pass 523 523 | pass
521 |+ 524 |+
522 |+ 525 |+
521 523 | def baz(): 524 526 | def baz(): pass
522 524 | pass 525 527 | # end
523 525 | # end 526 528 |
E30.py:531:1: E302 [*] Expected 2 blank lines, found 1 E30.py:530:1: E302 [*] Expected 2 blank lines, found 0
| |
530 | # comment 528 | # E302
531 | @decorator 529 | def bar(): pass
| ^ E302 530 | def baz():
532 | def g(): | ^^^ E302
533 | pass 531 | pass
532 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
527 527 | def f(): 527 527 |
528 528 | pass 528 528 | # E302
529 529 | 529 529 | def bar(): pass
530 |+ 530 |+
531 |+ 531 |+
530 532 | # comment 530 532 | def baz():
531 533 | @decorator 531 533 | pass
532 534 | def g(): 532 534 | # end
E30.py:540:1: E302 [*] Expected 2 blank lines, found 1
|
539 | # comment
540 | @decorator
| ^ E302
541 | def g():
542 | pass
|
= help: Add missing blank line(s)
Safe fix
536 536 | def f():
537 537 | pass
538 538 |
539 |+
540 |+
539 541 | # comment
540 542 | @decorator
541 543 | def g():

View file

@ -1,215 +1,250 @@
--- ---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
--- ---
E30.py:542:5: E303 [*] Too many blank lines (2) E30.py:555:2: E303 [*] Too many blank lines (2)
| |
542 | # arbitrary comment 555 | def method2():
| ^^^ E303
556 | return 22
557 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
551 551 | def method1():
552 552 | return 1
553 553 |
554 |-
555 554 | def method2():
556 555 | return 22
557 556 | # end
E30.py:565:5: E303 [*] Too many blank lines (2)
|
565 | # arbitrary comment
| ^^^^^^^^^^^^^^^^^^^ E303 | ^^^^^^^^^^^^^^^^^^^ E303
543 | 566 |
544 | def inner(): # E306 not expected (pycodestyle detects E306) 567 | def inner(): # E306 not expected (pycodestyle detects E306)
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
538 538 | def fn(): 561 561 | def fn():
539 539 | _ = None 562 562 | _ = None
540 540 |
541 |-
542 541 | # arbitrary comment
543 542 |
544 543 | def inner(): # E306 not expected (pycodestyle detects E306)
E30.py:554:5: E303 [*] Too many blank lines (2)
|
554 | # arbitrary comment
| ^^^^^^^^^^^^^^^^^^^ E303
555 | def inner(): # E306 not expected (pycodestyle detects E306)
556 | pass
|
= help: Remove extraneous blank line(s)
Safe fix
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:565:1: E303 [*] Too many blank lines (3)
|
565 | print()
| ^^^^^ E303
566 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
561 561 | print()
562 562 |
563 563 | 563 563 |
564 |- 564 |-
565 564 | print() 565 564 | # arbitrary comment
566 565 | # end 566 565 |
567 566 | 567 566 | def inner(): # E306 not expected (pycodestyle detects E306)
E30.py:574:1: E303 [*] Too many blank lines (3) E30.py:577:5: E303 [*] Too many blank lines (2)
| |
574 | # comment 577 | # arbitrary comment
| ^^^^^^^^^ E303 | ^^^^^^^^^^^^^^^^^^^ E303
575 | 578 | def inner(): # E306 not expected (pycodestyle detects E306)
576 | print() 579 | pass
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
570 570 | print() 573 573 | def fn():
571 571 | 574 574 | _ = None
572 572 | 575 575 |
573 |- 576 |-
574 573 | # comment 577 576 | # arbitrary comment
575 574 | 578 577 | def inner(): # E306 not expected (pycodestyle detects E306)
576 575 | print() 579 578 | pass
E30.py:585:5: E303 [*] Too many blank lines (2) E30.py:588:1: E303 [*] Too many blank lines (3)
| |
585 | # comment 588 | print()
| ^^^^^ E303
589 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
584 584 | print()
585 585 |
586 586 |
587 |-
588 587 | print()
589 588 | # end
590 589 |
E30.py:597:1: E303 [*] Too many blank lines (3)
|
597 | # comment
| ^^^^^^^^^ E303
598 |
599 | print()
|
= help: Remove extraneous blank line(s)
Safe fix
593 593 | print()
594 594 |
595 595 |
596 |-
597 596 | # comment
598 597 |
599 598 | print()
E30.py:608:5: E303 [*] Too many blank lines (2)
|
608 | # comment
| ^^^^^^^^^ E303 | ^^^^^^^^^ E303
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
581 581 | def a(): 604 604 | def a():
582 582 | print() 605 605 | print()
583 583 | 606 606 |
584 |- 607 |-
585 584 | # comment 608 607 | # comment
586 585 | 609 608 |
587 586 | 610 609 |
E30.py:588:5: E303 [*] Too many blank lines (2)
|
588 | # another comment
| ^^^^^^^^^^^^^^^^^ E303
589 |
590 | print()
|
= help: Remove extraneous blank line(s)
Safe fix
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
602 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
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:611:5: E303 [*] Too many blank lines (2) E30.py:611:5: E303 [*] Too many blank lines (2)
| |
611 | def b(self): 611 | # another comment
| ^^^ E303 | ^^^^^^^^^^^^^^^^^ E303
612 | pass 612 |
613 | # end 613 | print()
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
607 607 | def a(self): 607 607 |
608 608 | pass 608 608 | # comment
609 609 | 609 609 |
610 |- 610 |-
611 610 | def b(self): 611 610 | # another comment
612 611 | pass 612 611 |
613 612 | # end 613 612 | print()
E30.py:621:5: E303 [*] Too many blank lines (2) E30.py:622:1: E303 [*] Too many blank lines (3)
| |
621 | a = 2 622 | / """This class docstring comes on line 5.
| ^ E303 623 | | It gives error E303: too many blank lines (3)
622 | # end 624 | | """
| |___^ E303
625 | # end
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
617 617 | if True: 618 618 | #!python
618 618 | a = 1
619 619 | 619 619 |
620 |- 620 620 |
621 620 | a = 2 621 |-
622 621 | # end 622 621 | """This class docstring comes on line 5.
623 622 | 623 622 | It gives error E303: too many blank lines (3)
624 623 | """
E30.py:629:5: E303 [*] Too many blank lines (2) E30.py:634:5: E303 [*] Too many blank lines (2)
| |
629 | # comment 634 | def b(self):
| ^^^ E303
635 | pass
636 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
630 630 | def a(self):
631 631 | pass
632 632 |
633 |-
634 633 | def b(self):
635 634 | pass
636 635 | # end
E30.py:644:5: E303 [*] Too many blank lines (2)
|
644 | a = 2
| ^ E303
645 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
640 640 | if True:
641 641 | a = 1
642 642 |
643 |-
644 643 | a = 2
645 644 | # end
646 645 |
E30.py:652:5: E303 [*] Too many blank lines (2)
|
652 | # comment
| ^^^^^^^^^ E303 | ^^^^^^^^^ E303
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
625 625 | # E303 648 648 | # E303
626 626 | class Test: 649 649 | class Test:
627 627 | 650 650 |
628 |- 651 |-
629 628 | # comment 652 651 | # comment
630 629 | 653 652 |
631 630 | 654 653 |
E30.py:632:5: E303 [*] Too many blank lines (2) E30.py:655:5: E303 [*] Too many blank lines (2)
| |
632 | # another comment 655 | # another comment
| ^^^^^^^^^^^^^^^^^ E303 | ^^^^^^^^^^^^^^^^^ E303
633 | 656 |
634 | def test(self): pass 657 | def test(self): pass
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
628 628 | 651 651 |
629 629 | # comment 652 652 | # comment
630 630 | 653 653 |
631 |- 654 |-
632 631 | # another comment 655 654 | # another comment
633 632 | 656 655 |
634 633 | def test(self): pass 657 656 | def test(self): pass
E30.py:646:5: E303 [*] Too many blank lines (2) E30.py:669:5: E303 [*] Too many blank lines (2)
| |
646 | def b(self): 669 | def b(self):
| ^^^ E303 | ^^^ E303
647 | pass 670 | pass
648 | # end 671 | # end
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
642 642 | 665 665 |
643 643 | # wrongly indented comment 666 666 | # wrongly indented comment
644 644 | 667 667 |
645 |- 668 |-
646 645 | def b(self): 669 668 | def b(self):
647 646 | pass 670 669 | pass
648 647 | # end 671 670 | # end
E30.py:679:5: E303 [*] Too many blank lines (2)
|
679 | pass
| ^^^^ E303
680 | # end
|
= help: Remove extraneous blank line(s)
Safe fix
675 675 | def fn():
676 676 | pass
677 677 |
678 |-
679 678 | pass
680 679 | # end
681 680 |

View file

@ -1,65 +1,65 @@
--- ---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
--- ---
E30.py:654:1: E304 [*] Blank lines found after function decorator (1) E30.py:686:1: E304 [*] Blank lines found after function decorator (1)
| |
652 | @decorator 684 | @decorator
653 | 685 |
654 | def function(): 686 | def function():
| ^^^ E304 | ^^^ E304
655 | pass 687 | pass
656 | # end 688 | # end
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
650 650 | 682 682 |
651 651 | # E304 683 683 | # E304
652 652 | @decorator 684 684 | @decorator
653 |- 685 |-
654 653 | def function(): 686 685 | def function():
655 654 | pass 687 686 | pass
656 655 | # end 688 687 | # end
E30.py:663:1: E304 [*] Blank lines found after function decorator (1) E30.py:695:1: E304 [*] Blank lines found after function decorator (1)
| |
662 | # comment E304 not expected 694 | # comment E304 not expected
663 | def function(): 695 | def function():
| ^^^ E304 | ^^^ E304
664 | pass 696 | pass
665 | # end 697 | # end
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
658 658 | 690 690 |
659 659 | # E304 691 691 | # E304
660 660 | @decorator 692 692 | @decorator
661 |- 693 |-
662 661 | # comment E304 not expected 694 693 | # comment E304 not expected
663 662 | def function(): 695 694 | def function():
664 663 | pass 696 695 | pass
E30.py:675:1: E304 [*] Blank lines found after function decorator (2) E30.py:707:1: E304 [*] Blank lines found after function decorator (2)
| |
674 | # second comment E304 not expected 706 | # second comment E304 not expected
675 | def function(): 707 | def function():
| ^^^ E304 | ^^^ E304
676 | pass 708 | pass
677 | # end 709 | # end
| |
= help: Remove extraneous blank line(s) = help: Remove extraneous blank line(s)
Safe fix Safe fix
667 667 | 699 699 |
668 668 | # E304 700 700 | # E304
669 669 | @decorator 701 701 | @decorator
670 |- 702 |-
671 670 | # comment E304 not expected 703 702 | # comment E304 not expected
672 |- 704 |-
673 |- 705 |-
674 671 | # second comment E304 not expected 706 703 | # second comment E304 not expected
675 672 | def function(): 707 704 | def function():
676 673 | pass 708 705 | pass

View file

@ -1,102 +1,102 @@
--- ---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
--- ---
E30.py:687:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:719:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
686 | # another comment 718 | # another comment
687 | fn() 719 | fn()
| ^^ E305 | ^^ E305
688 | # end 720 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
684 684 | # comment 716 716 | # comment
685 685 | 717 717 |
686 686 | # another comment 718 718 | # another comment
687 |+ 719 |+
688 |+ 720 |+
687 689 | fn() 719 721 | fn()
688 690 | # end 720 722 | # end
689 691 | 721 723 |
E30.py:698:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:730:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
697 | # another comment 729 | # another comment
698 | a = 1 730 | a = 1
| ^ E305 | ^ E305
699 | # end 731 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
695 695 | # comment 727 727 | # comment
696 696 | 728 728 |
697 697 | # another comment 729 729 | # another comment
698 |+ 730 |+
699 |+ 731 |+
698 700 | a = 1 730 732 | a = 1
699 701 | # end 731 733 | # end
700 702 | 732 734 |
E30.py:710:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:742:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
708 | # another comment 740 | # another comment
709 | 741 |
710 | try: 742 | try:
| ^^^ E305 | ^^^ E305
711 | fn() 743 | fn()
712 | except Exception: 744 | except Exception:
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
707 707 | 739 739 |
708 708 | # another comment 740 740 | # another comment
709 709 | 741 741 |
710 |+ 742 |+
710 711 | try: 742 743 | try:
711 712 | fn() 743 744 | fn()
712 713 | except Exception: 744 745 | except Exception:
E30.py:722:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:754:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
721 | # Two spaces before comments, too. 753 | # Two spaces before comments, too.
722 | if a(): 754 | if a():
| ^^ E305 | ^^ E305
723 | a() 755 | a()
724 | # end 756 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
719 719 | print() 751 751 | print()
720 720 | 752 752 |
721 721 | # Two spaces before comments, too. 753 753 | # Two spaces before comments, too.
722 |+ 754 |+
723 |+ 755 |+
722 724 | if a(): 754 756 | if a():
723 725 | a() 755 757 | a()
724 726 | # end 756 758 | # end
E30.py:735:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:767:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
733 | blah, blah 765 | blah, blah
734 | 766 |
735 | if __name__ == '__main__': 767 | if __name__ == '__main__':
| ^^ E305 | ^^ E305
736 | main() 768 | main()
737 | # end 769 | # end
| |
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
732 732 | def main(): 764 764 | def main():
733 733 | blah, blah 765 765 | blah, blah
734 734 | 766 766 |
735 |+ 767 |+
735 736 | if __name__ == '__main__': 767 768 | if __name__ == '__main__':
736 737 | main() 768 769 | main()
737 738 | # end 769 770 | # end

View file

@ -1,223 +1,223 @@
--- ---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
--- ---
E30.py:743:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:775:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
741 | def a(): 773 | def a():
742 | x = 1 774 | x = 1
743 | def b(): 775 | def b():
| ^^^ E306 | ^^^ E306
744 | pass 776 | pass
745 | # end 777 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
740 740 | # E306:3:5 772 772 | # E306:3:5
741 741 | def a(): 773 773 | def a():
742 742 | x = 1 774 774 | x = 1
743 |+ 775 |+
743 744 | def b(): 775 776 | def b():
744 745 | pass 776 777 | pass
745 746 | # end 777 778 | # end
E30.py:751:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:783:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
749 | async def a(): 781 | async def a():
750 | x = 1 782 | x = 1
751 | def b(): 783 | def b():
| ^^^ E306 | ^^^ E306
752 | pass 784 | pass
753 | # end 785 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
748 748 | #: E306:3:5 780 780 | #: E306:3:5
749 749 | async def a(): 781 781 | async def a():
750 750 | x = 1 782 782 | x = 1
751 |+ 783 |+
751 752 | def b(): 783 784 | def b():
752 753 | pass 784 785 | pass
753 754 | # end 785 786 | # end
E30.py:759:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:791:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
757 | def a(): 789 | def a():
758 | x = 2 790 | x = 2
759 | def b(): 791 | def b():
| ^^^ E306 | ^^^ E306
760 | x = 1 792 | x = 1
761 | def c(): 793 | def c():
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
756 756 | #: E306:3:5 E306:5:9 788 788 | #: E306:3:5 E306:5:9
757 757 | def a(): 789 789 | def a():
758 758 | x = 2 790 790 | x = 2
759 |+ 791 |+
759 760 | def b(): 791 792 | def b():
760 761 | x = 1 792 793 | x = 1
761 762 | def c(): 793 794 | def c():
E30.py:761:9: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:793:9: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
759 | def b(): 791 | def b():
760 | x = 1 792 | x = 1
761 | def c(): 793 | def c():
| ^^^ E306 | ^^^ E306
762 | pass 794 | pass
763 | # end 795 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
758 758 | x = 2 790 790 | x = 2
759 759 | def b(): 791 791 | def b():
760 760 | x = 1 792 792 | x = 1
761 |+ 793 |+
761 762 | def c(): 793 794 | def c():
762 763 | pass 794 795 | pass
763 764 | # end 795 796 | # end
E30.py:769:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:801:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
767 | def a(): 799 | def a():
768 | x = 1 800 | x = 1
769 | class C: 801 | class C:
| ^^^^^ E306 | ^^^^^ E306
770 | pass 802 | pass
771 | x = 2 803 | x = 2
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
766 766 | # E306:3:5 E306:6:5 798 798 | # E306:3:5 E306:6:5
767 767 | def a(): 799 799 | def a():
768 768 | x = 1 800 800 | x = 1
769 |+ 801 |+
769 770 | class C: 801 802 | class C:
770 771 | pass 802 803 | pass
771 772 | x = 2 803 804 | x = 2
E30.py:772:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:804:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
770 | pass 802 | pass
771 | x = 2 803 | x = 2
772 | def b(): 804 | def b():
| ^^^ E306 | ^^^ E306
773 | pass 805 | pass
774 | # end 806 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
769 769 | class C: 801 801 | class C:
770 770 | pass 802 802 | pass
771 771 | x = 2 803 803 | x = 2
772 |+ 804 |+
772 773 | def b(): 804 805 | def b():
773 774 | pass 805 806 | pass
774 775 | # end 806 807 | # end
E30.py:781:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:813:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
779 | def bar(): 811 | def bar():
780 | pass 812 | pass
781 | def baz(): pass 813 | def baz(): pass
| ^^^ E306 | ^^^ E306
782 | # end 814 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
778 778 | def foo(): 810 810 | def foo():
779 779 | def bar(): 811 811 | def bar():
780 780 | pass 812 812 | pass
781 |+ 813 |+
781 782 | def baz(): pass 813 814 | def baz(): pass
782 783 | # end 814 815 | # end
783 784 | 815 816 |
E30.py:788:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:820:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
786 | def foo(): 818 | def foo():
787 | def bar(): pass 819 | def bar(): pass
788 | def baz(): 820 | def baz():
| ^^^ E306 | ^^^ E306
789 | pass 821 | pass
790 | # end 822 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
785 785 | # E306:3:5 817 817 | # E306:3:5
786 786 | def foo(): 818 818 | def foo():
787 787 | def bar(): pass 819 819 | def bar(): pass
788 |+ 820 |+
788 789 | def baz(): 820 821 | def baz():
789 790 | pass 821 822 | pass
790 791 | # end 822 823 | # end
E30.py:796:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:828:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
794 | def a(): 826 | def a():
795 | x = 2 827 | x = 2
796 | @decorator 828 | @decorator
| ^ E306 | ^ E306
797 | def b(): 829 | def b():
798 | pass 830 | pass
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
793 793 | # E306 825 825 | # E306
794 794 | def a(): 826 826 | def a():
795 795 | x = 2 827 827 | x = 2
796 |+ 828 |+
796 797 | @decorator 828 829 | @decorator
797 798 | def b(): 829 830 | def b():
798 799 | pass 830 831 | pass
E30.py:805:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:837:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
803 | def a(): 835 | def a():
804 | x = 2 836 | x = 2
805 | @decorator 837 | @decorator
| ^ E306 | ^ E306
806 | async def b(): 838 | async def b():
807 | pass 839 | pass
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
802 802 | # E306 834 834 | # E306
803 803 | def a(): 835 835 | def a():
804 804 | x = 2 836 836 | x = 2
805 |+ 837 |+
805 806 | @decorator 837 838 | @decorator
806 807 | async def b(): 838 839 | async def b():
807 808 | pass 839 840 | pass
E30.py:814:5: E306 [*] Expected 1 blank line before a nested definition, found 0 E30.py:846:5: E306 [*] Expected 1 blank line before a nested definition, found 0
| |
812 | def a(): 844 | def a():
813 | x = 2 845 | x = 2
814 | async def b(): 846 | async def b():
| ^^^^^ E306 | ^^^^^ E306
815 | pass 847 | pass
816 | # end 848 | # end
| |
= help: Add missing blank line = help: Add missing blank line
Safe fix Safe fix
811 811 | # E306 843 843 | # E306
812 812 | def a(): 844 844 | def a():
813 813 | x = 2 845 845 | x = 2
814 |+ 846 |+
814 815 | async def b(): 846 847 | async def b():
815 816 | pass 847 848 | pass
816 817 | # end 848 849 | # end