@@ -477,22 +477,14 @@ def get_object(self, name):
477
477
obj = getattr (obj , attributes .pop (0 ))
478
478
return obj
479
479
480
- def get_args (self ):
481
- """Check if an unclosed parenthesis exists, then attempt to get the
482
- argspec() for it. On success, update self.funcprops,self.arg_pos and
483
- return True, otherwise set self.funcprops to None and return False"""
484
-
485
- self .current_func = None
480
+ @classmethod
481
+ def _funcname_and_argnum (cls , line ):
482
+ """Name of the current function and where we are in args
486
483
487
- if not self .config .arg_spec :
488
- return False
489
-
490
- # Get the name of the current function and where we are in
491
- # the arguments
484
+ Returns (None, None) if can't be found."""
492
485
stack = [['' , 0 , '' ]]
493
486
try :
494
- for (token , value ) in PythonLexer ().get_tokens (
495
- self .current_line ):
487
+ for (token , value ) in PythonLexer ().get_tokens (line ):
496
488
if token is Token .Punctuation :
497
489
if value in '([{' :
498
490
stack .append (['' , 0 , value ])
@@ -522,8 +514,21 @@ def get_args(self):
522
514
stack .pop ()
523
515
_ , arg_number , _ = stack .pop ()
524
516
func , _ , _ = stack .pop ()
517
+ return func , arg_number
525
518
except IndexError :
519
+ return None , None
520
+
521
+ def get_args (self ):
522
+ """Check if an unclosed parenthesis exists, then attempt to get the
523
+ argspec() for it. On success, update self.funcprops,self.arg_pos and
524
+ return True, otherwise set self.funcprops to None and return False"""
525
+
526
+ self .current_func = None
527
+
528
+ if not self .config .arg_spec :
526
529
return False
530
+
531
+ func , arg_number = self ._funcname_and_argnum (self .current_line )
527
532
if not func :
528
533
return False
529
534
0 commit comments