Skip to content
Merged
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
5 changes: 5 additions & 0 deletions test_files/dont_touch_e501.expected.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if compat.py314:

from annotationlib import call_annotate_function # type: ignore[import-not-found,unused-ignore] # noqa: E501
from annotationlib import Format

5 changes: 5 additions & 0 deletions test_files/dont_touch_e501.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if compat.py314:

from annotationlib import call_annotate_function # type: ignore[import-not-found,unused-ignore] # noqa: E501
from annotationlib import Format

3 changes: 3 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def test_empty_file(self):
def test_conditional_imports(self):
self._assert_file("conditional_imports.py")

def test_dont_touch_e501(self):
self._assert_file("dont_touch_e501.py", opts=["--black-line-length", "79"],)

def test_sqla_test_file(self):
self._assert_file("sqla_test_file.py")

Expand Down
2 changes: 1 addition & 1 deletion zimports/zimports.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def _lines_with_newlines(lines) -> Iterator[str]:

def _mini_black_format(lines: list[str], line_length) -> Iterator[str]:
for line in lines:
if len(line) >= line_length:
if len(line) >= line_length and not re.search(r"noqa.*E501", line):
from_imp_match = re.match(r"^(\s*)from (.+?) import (.+)", line)
if not from_imp_match:
yield line
Expand Down