summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isort/_future/_dataclasses.py1
-rw-r--r--isort/api.py26
2 files changed, 12 insertions, 15 deletions
diff --git a/isort/_future/_dataclasses.py b/isort/_future/_dataclasses.py
index f7f6bace..8e2ff41a 100644
--- a/isort/_future/_dataclasses.py
+++ b/isort/_future/_dataclasses.py
@@ -1,5 +1,6 @@
# type: ignore
# flake8: noqa
+# flake8: noqa
"""Backport of Python3.7 dataclasses Library
Taken directly from here: https://github.com/ericvsmith/dataclasses
diff --git a/isort/api.py b/isort/api.py
index 14602378..c39b1b58 100644
--- a/isort/api.py
+++ b/isort/api.py
@@ -216,21 +216,17 @@ def sort_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().split("#")[0]
- 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
+ while stripped_line.endswith("\\") or ("(" in stripped_line and ")" not in stripped_line):
+ if stripped_line.endswith("\\"):
+ while stripped_line and stripped_line.endswith("\\"):
+ line = input_stream.readline()
+ stripped_line = line.strip().split("#")[0]
+ import_section += line
+ else:
+ while ")" not in stripped_line:
+ line = input_stream.readline()
+ stripped_line = line.strip().split("#")[0]
+ import_section += line
contains_imports = True
else: