1212from .settings import FILE_SKIP_COMMENTS
1313
1414CIMPORT_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 )
1616DOCSTRING_INDICATORS = ('"""' , "'''" )
17- COMMENT_INDICATORS = DOCSTRING_INDICATORS + ( "'" , '"' , "#" )
17+ COMMENT_INDICATORS = ( * DOCSTRING_INDICATORS , "'" , '"' , "#" )
1818CODE_SORT_COMMENTS = (
1919 "# isort: list" ,
2020 "# isort: dict" ,
@@ -180,11 +180,11 @@ def process(
180180 add_imports = [
181181 import_to_add
182182 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
184184 ]
185185
186186 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 ))
188188 and stripped_line .startswith ("#" )
189189 and stripped_line not in config .section_comments
190190 and stripped_line not in CODE_SORT_COMMENTS
@@ -199,11 +199,9 @@ def process(
199199 first_comment_index_end = index - 1
200200
201201 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 :
203203 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 (('"' , "'" )):
207205 first_comment_index_start = index
208206 while char_index < len (line ):
209207 if line [char_index ] == "\\ " :
@@ -287,9 +285,8 @@ def process(
287285 indent = line [: - len (line .lstrip ())]
288286 elif not (stripped_line or contains_imports ):
289287 not_imports = True
290- elif (
291- not stripped_line
292- or stripped_line .startswith ("#" )
288+ elif not stripped_line or (
289+ stripped_line .startswith ("#" )
293290 and (not indent or indent + line .lstrip () == line )
294291 and not config .treat_all_comments_as_code
295292 and stripped_line not in config .treat_comments_as_code
@@ -477,7 +474,7 @@ def process(
477474 output_stream .write (new_line )
478475 stripped_line = new_line .strip ().split ("#" )[0 ]
479476
480- if stripped_line .startswith ("raise" ) or stripped_line . startswith ( "yield" ):
477+ if stripped_line .startswith (( "raise" , "yield" ) ):
481478 while stripped_line .endswith ("\\ " ):
482479 new_line = input_stream .readline ()
483480 if not new_line :
0 commit comments