12
12
from .settings import FILE_SKIP_COMMENTS
13
13
14
14
CIMPORT_IDENTIFIERS = ("cimport " , "cimport*" , "from.cimport" )
15
- IMPORT_START_IDENTIFIERS = ("from " , "from.import" , "import " , "import*" ) + CIMPORT_IDENTIFIERS
15
+ IMPORT_START_IDENTIFIERS = ("from " , "from.import" , "import " , "import*" , * CIMPORT_IDENTIFIERS )
16
16
DOCSTRING_INDICATORS = ('"""' , "'''" )
17
- COMMENT_INDICATORS = DOCSTRING_INDICATORS + ( "'" , '"' , "#" )
17
+ COMMENT_INDICATORS = ( * DOCSTRING_INDICATORS , "'" , '"' , "#" )
18
18
CODE_SORT_COMMENTS = (
19
19
"# isort: list" ,
20
20
"# isort: dict" ,
@@ -180,11 +180,11 @@ def process(
180
180
add_imports = [
181
181
import_to_add
182
182
for import_to_add in add_imports
183
- if not import_to_add = = import_not_to_add
183
+ if import_to_add ! = import_not_to_add
184
184
]
185
185
186
186
if (
187
- (index == 0 or (index in ( 1 , 2 ) and not contains_imports ))
187
+ (index == 0 or (index in { 1 , 2 } and not contains_imports ))
188
188
and stripped_line .startswith ("#" )
189
189
and stripped_line not in config .section_comments
190
190
and stripped_line not in CODE_SORT_COMMENTS
@@ -199,11 +199,9 @@ def process(
199
199
first_comment_index_end = index - 1
200
200
201
201
was_in_quote = bool (in_quote )
202
- if (not stripped_line .startswith ("#" ) or in_quote ) and '"' in line or "'" in line :
202
+ if (( not stripped_line .startswith ("#" ) or in_quote ) and '"' in line ) or "'" in line :
203
203
char_index = 0
204
- if first_comment_index_start == - 1 and (
205
- line .startswith ('"' ) or line .startswith ("'" )
206
- ):
204
+ if first_comment_index_start == - 1 and line .startswith (('"' , "'" )):
207
205
first_comment_index_start = index
208
206
while char_index < len (line ):
209
207
if line [char_index ] == "\\ " :
@@ -287,9 +285,8 @@ def process(
287
285
indent = line [: - len (line .lstrip ())]
288
286
elif not (stripped_line or contains_imports ):
289
287
not_imports = True
290
- elif (
291
- not stripped_line
292
- or stripped_line .startswith ("#" )
288
+ elif not stripped_line or (
289
+ stripped_line .startswith ("#" )
293
290
and (not indent or indent + line .lstrip () == line )
294
291
and not config .treat_all_comments_as_code
295
292
and stripped_line not in config .treat_comments_as_code
@@ -477,7 +474,7 @@ def process(
477
474
output_stream .write (new_line )
478
475
stripped_line = new_line .strip ().split ("#" )[0 ]
479
476
480
- if stripped_line .startswith ("raise" ) or stripped_line . startswith ( "yield" ):
477
+ if stripped_line .startswith (( "raise" , "yield" ) ):
481
478
while stripped_line .endswith ("\\ " ):
482
479
new_line = input_stream .readline ()
483
480
if not new_line :
0 commit comments