@@ -292,17 +292,18 @@ def find_pre_312(cls, tokens_by_line):
292292 def find_post_312 (cls , tokens_by_line ):
293293 for line in tokens_by_line :
294294 assign_ix = _find_assign_op (line )
295- if (assign_ix is not None ) \
296- and not line [assign_ix ].line .strip ().startswith ('=' ) \
297- and (len (line ) >= assign_ix + 2 ) \
298- and (line [assign_ix + 1 ].type == tokenize .OP ) \
299- and (line [assign_ix + 1 ].string == '!' ):
295+ if (
296+ (assign_ix is not None )
297+ and not line [assign_ix ].line .strip ().startswith ("=" )
298+ and (len (line ) >= assign_ix + 2 )
299+ and (line [assign_ix + 1 ].type == tokenize .OP )
300+ and (line [assign_ix + 1 ].string == "!" )
301+ ):
300302 return cls (line [assign_ix + 1 ].start )
301303
302304 @classmethod
303305 def find (cls , tokens_by_line ):
304- """Find the first system assignment (a = !foo) in the cell.
305- """
306+ """Find the first system assignment (a = !foo) in the cell."""
306307 if sys .version_info < (3 , 12 ):
307308 return cls .find_pre_312 (tokens_by_line )
308309 return cls .find_post_312 (tokens_by_line )
@@ -531,8 +532,9 @@ def make_tokens_by_line(lines:List[str]):
531532 )
532533 parenlev = 0
533534 try :
534- for token in tokenutil .generate_tokens_catch_errors (iter (lines ).__next__ ,
535- extra_errors_to_catch = ['expected EOF' ]):
535+ for token in tokenutil .generate_tokens_catch_errors (
536+ iter (lines ).__next__ , extra_errors_to_catch = ["expected EOF" ]
537+ ):
536538 tokens_by_line [- 1 ].append (token )
537539 if (token .type == NEWLINE ) \
538540 or ((token .type == NL ) and (parenlev <= 0 )):
@@ -701,8 +703,8 @@ def check_complete(self, cell: str):
701703 for line in reversed (lines ):
702704 if not line .strip ():
703705 continue
704- elif line .strip (' \n ' ).endswith (' \\ ' ):
705- return ' incomplete' , find_last_indent (lines )
706+ elif line .strip (" \n " ).endswith (" \\ " ):
707+ return " incomplete" , find_last_indent (lines )
706708 else :
707709 break
708710
@@ -742,8 +744,10 @@ def check_complete(self, cell: str):
742744 if not tokens_by_line :
743745 return 'incomplete' , find_last_indent (lines )
744746
745- if (tokens_by_line [- 1 ][- 1 ].type != tokenize .ENDMARKER
746- and tokens_by_line [- 1 ][- 1 ].type != tokenize .ERRORTOKEN ):
747+ if (
748+ tokens_by_line [- 1 ][- 1 ].type != tokenize .ENDMARKER
749+ and tokens_by_line [- 1 ][- 1 ].type != tokenize .ERRORTOKEN
750+ ):
747751 # We're in a multiline string or expression
748752 return 'incomplete' , find_last_indent (lines )
749753
0 commit comments