Skip to content

Commit 7960bf7

Browse files
Simpler strategy for following line continuations
1 parent 67fb11b commit 7960bf7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

isort/core.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def process(
6767
made_changes: bool = False
6868
stripped_line: str = ""
6969
end_of_file: bool = False
70-
in_line_continuation: bool = False
7170

7271
if config.float_to_top:
7372
new_input = ""
@@ -229,7 +228,7 @@ def process(
229228
):
230229
import_section += line
231230
elif (
232-
stripped_line.startswith(IMPORT_START_IDENTIFIERS) and not in_line_continuation
231+
stripped_line.startswith(IMPORT_START_IDENTIFIERS)
233232
):
234233
contains_imports = True
235234

@@ -273,10 +272,9 @@ def process(
273272
indent = new_indent
274273
import_section += import_statement
275274
else:
276-
if stripped_line.endswith("\\"):
277-
in_line_continuation = True
278-
else:
279-
in_line_continuation = False
275+
while stripped_line.endswith("\\"):
276+
line += input_stream.readline()
277+
stripped_line = line.strip().split("#")[0]
280278
not_imports = True
281279

282280
if not_imports:

0 commit comments

Comments
 (0)