summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Edmund Crosley <timothy.crosley@gmail.com>2021-03-20 00:17:14 -0700
committerGitHub <noreply@github.com>2021-03-20 00:17:14 -0700
commit43cfa4752acf9a64124aadfcbc11747afd0d9391 (patch)
tree38a63bb27738c065bc621fcbe538b91e87d50402
parent5a0ebba5174d67210b6b23f8f644f1b0bc03de73 (diff)
parent404d809a692d68db0f36016b91171befec48be81 (diff)
downloadisort-43cfa4752acf9a64124aadfcbc11747afd0d9391.tar.gz
Merge pull request #1694 from PyCQA/issue/1566
Issue/1566
-rw-r--r--CHANGELOG.md1
-rw-r--r--isort/output.py8
-rw-r--r--tests/unit/test_regressions.py12
3 files changed, 20 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d0a99b2..4a805715 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/
- Fixed #1631: as import comments can in some cases be duplicated.
- Fixed #1667: extra newline added with float-to-top, after skip, in some cases.
- Fixed #1594: incorrect placement of noqa comments with multiple from imports.
+ - Fixed #1566: in some cases different length limits for dos based line endings.
- Implemented #1648: Export MyPY type hints.
- Implemented #1641: Identified import statements now return runnable code.
- Implemented #1661: Added "wemake" profile.
diff --git a/isort/output.py b/isort/output.py
index 13f72a3d..61c2e30e 100644
--- a/isort/output.py
+++ b/isort/output.py
@@ -504,7 +504,13 @@ def _with_from_imports(
config=config,
multi_line_output=wrap.Modes.VERTICAL_GRID, # type: ignore
)
- if max(len(x) for x in import_statement.split("\n")) > config.line_length:
+ if (
+ max(
+ len(import_line)
+ for import_line in import_statement.split(parsed.line_separator)
+ )
+ > config.line_length
+ ):
import_statement = other_import_statement
if not do_multiline_reformat and len(import_statement) > config.line_length:
import_statement = wrap.line(import_statement, parsed.line_separator, config)
diff --git a/tests/unit/test_regressions.py b/tests/unit/test_regressions.py
index 9f175525..26517598 100644
--- a/tests/unit/test_regressions.py
+++ b/tests/unit/test_regressions.py
@@ -1607,3 +1607,15 @@ from .test import ( # noqa: F401
)
"""
)
+
+
+def test_isort_correctly_handles_unix_vs_linux_newlines_issue_1566():
+ import_statement = (
+ "from impacket.smb3structs import (\n"
+ "SMB2_CREATE, SMB2_FLAGS_DFS_OPERATIONS, SMB2_IL_IMPERSONATION, "
+ "SMB2_OPLOCK_LEVEL_NONE, SMB2Create,"
+ "\nSMB2Create_Response, SMB2Packet)\n"
+ )
+ assert isort.code(import_statement, line_length=120) == isort.code(
+ import_statement.replace("\n", "\r\n"), line_length=120
+ ).replace("\r\n", "\n")