diff --git a/isort/api.py b/isort/api.py index 58367f3e0..873d77bfd 100644 --- a/isort/api.py +++ b/isort/api.py @@ -398,7 +398,7 @@ def _sort_imports( else: stripped_line = line.strip() if stripped_line and not line_separator: - line_separator = line[len(line.rstrip()):] + line_separator = line[len(line.rstrip()) :] for file_skip_comment in FILE_SKIP_COMMENTS: if file_skip_comment in line: diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 8b751e318..6910f9914 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -231,8 +231,8 @@ def test_windows_newline_issue_1277(): See: https://github.com/timothycrosley/isort/issues/1277 """ assert ( - isort.code("\ndef main():\r\n import time\r\n\n import sys\r\n") == - "\ndef main():\r\n import sys\r\n import time\r\n" + isort.code("\ndef main():\r\n import time\r\n\n import sys\r\n") + == "\ndef main():\r\n import sys\r\n import time\r\n" )