@@ -1453,45 +1453,69 @@ def visit_call(self, node: nodes.Call) -> None:
14531453 """Check that called functions/methods are inferred to callable objects,
14541454 and that passed arguments match the parameters in the inferred function.
14551455 """
1456- called = safe_infer (node .func , compare_constructors = True )
1456+ def _dp (s , val = None ):
1457+ if val is None :
1458+ print (f" { s } " , flush = True )
1459+ else :
1460+ print (f" { s } : { val } " , flush = True )
1461+ _dp ("-" * 25 )
1462+ _dp ("visit call, node" , node )
14571463
1464+ called = safe_infer (node .func , compare_constructors = True )
1465+ _dp ("a" )
14581466 self ._check_not_callable (node , called )
1459-
1467+ _dp ( "b" )
14601468 try :
1469+ _dp ("c" )
14611470 called , implicit_args , callable_name = _determine_callable (called )
1471+ _dp ("d" )
14621472 except ValueError :
14631473 # Any error occurred during determining the function type, most of
14641474 # those errors are handled by different warnings.
1475+ _dp ("e" )
14651476 return
14661477
1478+ _dp ("f" )
14671479 if called .args .args is None :
1480+ _dp ("g" )
14681481 if called .name == "isinstance" :
14691482 # Verify whether second argument of isinstance is a valid type
1483+ _dp ("h" )
14701484 self ._check_isinstance_args (node , callable_name )
14711485 # Built-in functions have no argument information.
1486+ _dp ("i" )
14721487 return
14731488
1489+ _dp ("j" )
14741490 if len (called .argnames ()) != len (set (called .argnames ())):
14751491 # Duplicate parameter name (see duplicate-argument). We can't really
14761492 # make sense of the function call in this case, so just return.
1493+ _dp ("k" )
14771494 return
14781495
14791496 # Build the set of keyword arguments, checking for duplicate keywords,
14801497 # and count the positional arguments.
1498+ _dp ("L" )
14811499 call_site = astroid .arguments .CallSite .from_call (node )
14821500
14831501 # Warn about duplicated keyword arguments, such as `f=24, **{'f': 24}`
1502+ _dp ("m" )
14841503 for keyword in call_site .duplicated_keywords :
1504+ _dp ("N" )
14851505 self .add_message ("repeated-keyword" , node = node , args = (keyword ,))
14861506
1507+ _dp ("O" )
14871508 if call_site .has_invalid_arguments () or call_site .has_invalid_keywords ():
14881509 # Can't make sense of this.
1510+ _dp ("p" )
14891511 return
14901512
14911513 # Has the function signature changed in ways we cannot reliably detect?
1514+ _dp ("q" )
14921515 if hasattr (called , "decorators" ) and decorated_with (
14931516 called , self .linter .config .signature_mutators
14941517 ):
1518+ _dp ("R" )
14951519 return
14961520
14971521 num_positional_args = len (call_site .positional_arguments )
@@ -1523,14 +1547,25 @@ def visit_call(self, node: nodes.Call) -> None:
15231547 # inside the class where the function is defined.
15241548 # This avoids emitting `too-many-function-args` since `num_positional_args`
15251549 # includes an implicit `self` argument which is not present in `called.args`.
1550+ _dp ("NOTE: about to dec" )
1551+ _dp ("node frame" , node .frame ())
1552+ _dp ("isinst" , isinstance (node .frame (), nodes .ClassDef ))
1553+ _dp ("funcdef" , isinstance (called , nodes .FunctionDef ))
1554+ _dp ("called" , called )
1555+ _dp ("frame body" , node .frame ().body )
1556+ _dp ("called in frame body" , called in node .frame ().body )
1557+ _dp ("npa" , num_positional_args )
1558+ _dp ("dec names" , called .decoratornames ())
15261559 if (
15271560 isinstance (node .frame (), nodes .ClassDef )
15281561 and isinstance (called , nodes .FunctionDef )
15291562 and called in node .frame ().body
15301563 and num_positional_args > 0
15311564 and "builtins.staticmethod" not in called .decoratornames ()
15321565 ):
1566+ _dp ("NOTE: decrementing" )
15331567 num_positional_args -= 1
1568+ _dp ("NOTE: dec done" )
15341569
15351570 # Analyze the list of formal parameters.
15361571 args = list (itertools .chain (called .args .posonlyargs or (), called .args .args ))
0 commit comments