summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2019-12-06 23:03:44 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2019-12-06 23:03:44 -0800
commit896d6ce0ca81f49fee5816e1af55dcde3e51c075 (patch)
treeaa7ff388097c660c704a7865c6806a92c8163483
parent0c4c155fa4adc05bdb157cbcff12f17b3e4392e7 (diff)
downloadisort-896d6ce0ca81f49fee5816e1af55dcde3e51c075.tar.gz
Attempt to deal with \ and ( \n \n ) continuouations
-rw-r--r--isort/parse.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/isort/parse.py b/isort/parse.py
index f5c792d5..b5b285ae 100644
--- a/isort/parse.py
+++ b/isort/parse.py
@@ -510,6 +510,22 @@ def identify_contiguous_imports(
import_section += line
elif stripped_line.startswith(IMPORT_START_IDENTIFIERS):
import_section += line
+ if "(" in stripped_line and not ")" in stripped_line:
+ nested_line = line
+ nested_stripped_line = nested_line.strip()
+ while not ")" in nested_stripped_line:
+ nested_line = input_stream.readline()
+ nested_stripped_line = nested_line.strip()
+ import_section += nested_line
+
+ if stripped_line.endswith("\\"):
+ nested_line = line
+ nested_stripped_line = nested_line.strip()
+ while nested_line and nested_stripped_line.endswith("\\"):
+ nested_line = input_stream.readline()
+ nested_stripped_line = nested_line.strip()
+ import_section += nested_line
+
contains_imports = True
else:
not_imports = True