summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isort/isort.py3
-rw-r--r--test_isort.py10
2 files changed, 11 insertions, 2 deletions
diff --git a/isort/isort.py b/isort/isort.py
index c15b3cb0..3e2db2af 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -854,7 +854,6 @@ class SortImports(object):
if self.import_index == -1:
self.import_index = self.index - 1
-
nested_comments = {}
import_string, comments, new_comments = self._strip_comments(line)
stripped_line = [part for part in self._strip_syntax(import_string).strip().split(" ") if part]
@@ -873,7 +872,7 @@ class SortImports(object):
line, comments, new_comments = self._strip_comments(self._get_line(), comments)
# Still need to check for parentheses after an escaped line
- if "(" in line.split("#")[0] and not self._at_end():
+ if "(" in line.split("#")[0] and not ")" in line.split("#")[0] and not self._at_end():
stripped_line = self._strip_syntax(line).strip()
if import_type == "from" and stripped_line and " " not in stripped_line and new_comments:
nested_comments[stripped_line] = comments[-1]
diff --git a/test_isort.py b/test_isort.py
index aafafceb..19fb0540 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -2742,3 +2742,13 @@ def test_inconsistent_relative_imports_issue_577():
'from ...eu import dignissim\n'
'from ...ex import metus\n')
assert SortImports(file_contents=test_input, force_single_line=True).output == test_input
+
+
+def test_unwrap_issue_762():
+ test_input = ('from os.path \\\n'
+ 'import (join, split)\n')
+ assert SortImports(file_contents=test_input).output == 'from os.path import join, split\n'
+
+ test_input = ('from os.\\\n'
+ ' path import (join, split)')
+ assert SortImports(file_contents=test_input).output == 'from os.path import join, split\n'