Skip to content

Commit 2abab2a

Browse files
dgwsigmavirus24
authored andcommitted
Add I301 check for if TYPE_CHECKING: separated from other imports
1 parent 5b25d53 commit 2abab2a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

flake8_import_order/styles.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def _check(self, previous_import, previous, current_import):
4848
and current_import.type_checking
4949
):
5050
yield from self._check_I300(previous_import, current_import)
51+
yield from self._check_I301(previous_import, current_import)
5152
previous_import = None
5253
if previous_import is not None:
5354
yield from self._check_I100(previous_import, current_import)
@@ -78,13 +79,21 @@ def _check_I101(self, current_import): # noqa: N802
7879
)
7980

8081
def _check_I300(self, previous_import, current_import): # noqa: N802
81-
if current_import.lineno - previous_import.end_lineno != 3:
82+
if current_import.lineno - previous_import.end_lineno < 3:
8283
yield Error(
8384
current_import.lineno,
8485
"I300",
8586
"TYPE_CHECKING block should have one newline above.",
8687
)
8788

89+
def _check_I301(self, previous_import, current_import): # noqa: N802
90+
if current_import.lineno - previous_import.end_lineno > 3:
91+
yield Error(
92+
current_import.lineno,
93+
"I301",
94+
"TYPE_CHECKING block should have no more than one newline above.",
95+
)
96+
8897
def _check_I100(self, previous_import, current_import): # noqa: N802
8998
previous_key = self.import_key(previous_import)
9099
current_key = self.import_key(current_import)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# cryptography edited google pep8 smarkets
2+
from typing import TYPE_CHECKING
3+
4+
import pytest
5+
6+
from . import localpackage
7+
8+
CONST = localpackage.CONST
9+
10+
if TYPE_CHECKING:
11+
import ast # I301

0 commit comments

Comments
 (0)