Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion flake8_import_order/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def _check(self, previous_import, previous, current_import):
and current_import.type_checking
):
yield from self._check_I300(previous_import, current_import)
yield from self._check_I301(previous_import, current_import)
previous_import = None
if previous_import is not None:
yield from self._check_I100(previous_import, current_import)
Expand Down Expand Up @@ -78,13 +79,21 @@ def _check_I101(self, current_import): # noqa: N802
)

def _check_I300(self, previous_import, current_import): # noqa: N802
if current_import.lineno - previous_import.end_lineno != 3:
if current_import.lineno - previous_import.end_lineno < 3:
yield Error(
current_import.lineno,
"I300",
"TYPE_CHECKING block should have one newline above.",
)

def _check_I301(self, previous_import, current_import): # noqa: N802
if current_import.lineno - previous_import.end_lineno > 3:
yield Error(
current_import.lineno,
"I301",
"TYPE_CHECKING block should have no more than one newline above.",
)

def _check_I100(self, previous_import, current_import): # noqa: N802
previous_key = self.import_key(previous_import)
current_key = self.import_key(current_import)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cases/type_checking_orphaned.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# cryptography edited google pep8 smarkets
from typing import TYPE_CHECKING

import pytest

from . import localpackage

CONST = localpackage.CONST

if TYPE_CHECKING:
import ast # I301