Skip to content

Commit

Permalink
Test blank lines after nested imports
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Mar 1, 2024
1 parent 275dda7 commit 94d04a6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class BackendProxy:

abcd.foo()


def __init__(self, backend_module: str, backend_obj: str | None) -> None: ...

if TYPE_CHECKING:
from typing_extensions import TypeAlias

def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: ...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,11 @@ impl<'a> BlankLinesChecker<'a> {
}
LogicalLineKind::Comment => {}
LogicalLineKind::Import => {
state.follows = Follows::Import;
state.follows = if logical_line.indent_length == 0 {
Follows::Import
} else {
Follows::Other
}
}
LogicalLineKind::Other => {
state.follows = Follows::Other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,42 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted
6 |-
7 4 |
8 5 | class MissingCommand(TypeError): ... # noqa: N818
9 6 |
9 6 |

E30_isort.py:24:1: E302 [*] Expected 2 blank lines, found 1
|
22 | abcd.foo()
23 |
24 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ...
| ^^^ E302
25 |
26 | if TYPE_CHECKING:
|
= help: Add missing blank line(s)

Safe fix
21 21 |
22 22 | abcd.foo()
23 23 |
24 |+
24 25 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ...
25 26 |
26 27 | if TYPE_CHECKING:

E30_isort.py:29:1: E302 [*] Expected 2 blank lines, found 1
|
27 | from typing_extensions import TypeAlias
28 |
29 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: ...
| ^^^ E302
|
= help: Add missing blank line(s)

Safe fix
26 26 | if TYPE_CHECKING:
27 27 | from typing_extensions import TypeAlias
28 28 |
29 |+
29 30 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: ...
30 31 |
31 32 |
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ E30_isort.py:22:5: E303 [*] Too many blank lines (3)
|
22 | abcd.foo()
| ^^^^ E303
23 |
24 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ...
|
= help: Remove extraneous blank line(s)

Expand All @@ -41,4 +43,4 @@ E30_isort.py:22:5: E303 [*] Too many blank lines (3)
21 |-
22 20 | abcd.foo()
23 21 |
24 22 |
24 22 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ...

0 comments on commit 94d04a6

Please sign in to comment.