@@ -321,15 +321,13 @@ def __init__(self, options):
321321 self .__freshmodule = 1
322322 self .__curfile = None
323323 self .__enclosurecount = 0
324- self .__prev_token = None
325324
326325 def __call__ (self , ttype , tstring , stup , etup , line ):
327326 # dispatch
328327## import token
329328## print('ttype:', token.tok_name[ttype], 'tstring:', tstring,
330329## file=sys.stderr)
331330 self .__state (ttype , tstring , stup [0 ])
332- self .__prev_token = (ttype , tstring , stup , etup , line )
333331
334332 def __waiting (self , ttype , tstring , lineno ):
335333 opts = self .__options
@@ -348,10 +346,10 @@ def __waiting(self, ttype, tstring, lineno):
348346 if ttype == tokenize .NAME and tstring in ('class' , 'def' ):
349347 self .__state = self .__suiteseen
350348 return
351- if (
352- ttype == tokenize . NAME and tstring in opts . keywords
353- and ( not self . __prev_token or not _is_def_or_class_keyword ( self . __prev_token ))
354- ) :
349+ if ttype == tokenize . NAME and tstring in ( 'class' , 'def' ):
350+ self . __state = self . __ignorenext
351+ return
352+ if ttype == tokenize . NAME and tstring in opts . keywords :
355353 self .__state = self .__keywordseen
356354 return
357355 if ttype == tokenize .STRING :
@@ -458,6 +456,9 @@ def __openseen(self, ttype, tstring, lineno):
458456 }, file = sys .stderr )
459457 self .__state = self .__waiting
460458
459+ def __ignorenext (self , ttype , tstring , lineno ):
460+ self .__state = self .__waiting
461+
461462 def __addentry (self , msg , lineno = None , isdocstring = 0 ):
462463 if lineno is None :
463464 lineno = self .__lineno
0 commit comments