@@ -270,20 +270,6 @@ def process(
270
270
indent = new_indent
271
271
import_section += import_statement
272
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
-
282
- while stripped_line .endswith ("\\ " ):
283
- new_line = input_stream .readline ()
284
- line += new_line
285
- stripped_line = new_line .strip ().split ("#" )[0 ]
286
-
287
273
not_imports = True
288
274
289
275
if not_imports :
@@ -320,6 +306,7 @@ def process(
320
306
raw_import_section += line
321
307
if not contains_imports :
322
308
output_stream .write (import_section )
309
+
323
310
else :
324
311
leading_whitespace = import_section [: - len (import_section .lstrip ())]
325
312
trailing_whitespace = import_section [len (import_section .rstrip ()) :]
@@ -375,6 +362,34 @@ def process(
375
362
output_stream .write (line )
376
363
not_imports = False
377
364
365
+ if stripped_line and not in_quote and not import_section and not next_import_section :
366
+ if stripped_line == "yield" :
367
+ while not stripped_line or stripped_line == "yield" :
368
+ new_line = input_stream .readline ()
369
+ if not new_line :
370
+ break
371
+
372
+ output_stream .write (new_line )
373
+ stripped_line = new_line .strip ().split ("#" )[0 ]
374
+
375
+ if stripped_line .startswith ("raise" ) or stripped_line .startswith ("yield" ):
376
+ if "(" in stripped_line :
377
+ while ")" not in stripped_line :
378
+ new_line = input_stream .readline ()
379
+ if not new_line :
380
+ break
381
+
382
+ output_stream .write (new_line )
383
+ stripped_line = new_line .strip ().split ("#" )[0 ]
384
+
385
+ while stripped_line .endswith ("\\ " ):
386
+ new_line = input_stream .readline ()
387
+ if not new_line :
388
+ break
389
+
390
+ output_stream .write (new_line )
391
+ stripped_line = new_line .strip ().split ("#" )[0 ]
392
+
378
393
return made_changes
379
394
380
395
0 commit comments