File tree 2 files changed +15
-7
lines changed
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -227,9 +227,7 @@ def process(
227
227
and stripped_line not in config .treat_comments_as_code
228
228
):
229
229
import_section += line
230
- elif (
231
- stripped_line .startswith (IMPORT_START_IDENTIFIERS )
232
- ):
230
+ elif stripped_line .startswith (IMPORT_START_IDENTIFIERS ):
233
231
contains_imports = True
234
232
235
233
new_indent = line [: - len (line .lstrip ())]
@@ -272,9 +270,20 @@ def process(
272
270
indent = new_indent
273
271
import_section += import_statement
274
272
else :
273
+ if not import_section and "(" in stripped_line :
274
+ while ")" not in stripped_line :
275
+ new_line = input_stream .readline ()
276
+ if not new_line :
277
+ break
278
+
279
+ line += new_line
280
+ stripped_line = new_line .strip ().split ("#" )[0 ]
281
+
275
282
while stripped_line .endswith ("\\ " ):
276
- line += input_stream .readline ()
277
- stripped_line = line .strip ().split ("#" )[0 ]
283
+ new_line = input_stream .readline ()
284
+ line += new_line
285
+ stripped_line = new_line .strip ().split ("#" )[0 ]
286
+
278
287
not_imports = True
279
288
280
289
if not_imports :
Original file line number Diff line number Diff line change @@ -1006,7 +1006,7 @@ def function():
1006
1006
import a
1007
1007
"""
1008
1008
assert isort .check_code (will_ignore_if_non_comment_continuation , show_diff = True )
1009
-
1009
+
1010
1010
yield_from_parens_should_be_ignored = """
1011
1011
def generator_function():
1012
1012
(
@@ -1015,4 +1015,3 @@ def generator_function():
1015
1015
)
1016
1016
"""
1017
1017
assert isort .check_code (yield_from_parens_should_be_ignored , show_diff = True )
1018
-
You can’t perform that action at this time.
0 commit comments