@@ -1453,45 +1453,69 @@ def visit_call(self, node: nodes.Call) -> None:
1453
1453
"""Check that called functions/methods are inferred to callable objects,
1454
1454
and that passed arguments match the parameters in the inferred function.
1455
1455
"""
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 )
1457
1463
1464
+ called = safe_infer (node .func , compare_constructors = True )
1465
+ _dp ("a" )
1458
1466
self ._check_not_callable (node , called )
1459
-
1467
+ _dp ( "b" )
1460
1468
try :
1469
+ _dp ("c" )
1461
1470
called , implicit_args , callable_name = _determine_callable (called )
1471
+ _dp ("d" )
1462
1472
except ValueError :
1463
1473
# Any error occurred during determining the function type, most of
1464
1474
# those errors are handled by different warnings.
1475
+ _dp ("e" )
1465
1476
return
1466
1477
1478
+ _dp ("f" )
1467
1479
if called .args .args is None :
1480
+ _dp ("g" )
1468
1481
if called .name == "isinstance" :
1469
1482
# Verify whether second argument of isinstance is a valid type
1483
+ _dp ("h" )
1470
1484
self ._check_isinstance_args (node , callable_name )
1471
1485
# Built-in functions have no argument information.
1486
+ _dp ("i" )
1472
1487
return
1473
1488
1489
+ _dp ("j" )
1474
1490
if len (called .argnames ()) != len (set (called .argnames ())):
1475
1491
# Duplicate parameter name (see duplicate-argument). We can't really
1476
1492
# make sense of the function call in this case, so just return.
1493
+ _dp ("k" )
1477
1494
return
1478
1495
1479
1496
# Build the set of keyword arguments, checking for duplicate keywords,
1480
1497
# and count the positional arguments.
1498
+ _dp ("L" )
1481
1499
call_site = astroid .arguments .CallSite .from_call (node )
1482
1500
1483
1501
# Warn about duplicated keyword arguments, such as `f=24, **{'f': 24}`
1502
+ _dp ("m" )
1484
1503
for keyword in call_site .duplicated_keywords :
1504
+ _dp ("N" )
1485
1505
self .add_message ("repeated-keyword" , node = node , args = (keyword ,))
1486
1506
1507
+ _dp ("O" )
1487
1508
if call_site .has_invalid_arguments () or call_site .has_invalid_keywords ():
1488
1509
# Can't make sense of this.
1510
+ _dp ("p" )
1489
1511
return
1490
1512
1491
1513
# Has the function signature changed in ways we cannot reliably detect?
1514
+ _dp ("q" )
1492
1515
if hasattr (called , "decorators" ) and decorated_with (
1493
1516
called , self .linter .config .signature_mutators
1494
1517
):
1518
+ _dp ("R" )
1495
1519
return
1496
1520
1497
1521
num_positional_args = len (call_site .positional_arguments )
@@ -1523,14 +1547,25 @@ def visit_call(self, node: nodes.Call) -> None:
1523
1547
# inside the class where the function is defined.
1524
1548
# This avoids emitting `too-many-function-args` since `num_positional_args`
1525
1549
# 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 ())
1526
1559
if (
1527
1560
isinstance (node .frame (), nodes .ClassDef )
1528
1561
and isinstance (called , nodes .FunctionDef )
1529
1562
and called in node .frame ().body
1530
1563
and num_positional_args > 0
1531
1564
and "builtins.staticmethod" not in called .decoratornames ()
1532
1565
):
1566
+ _dp ("NOTE: decrementing" )
1533
1567
num_positional_args -= 1
1568
+ _dp ("NOTE: dec done" )
1534
1569
1535
1570
# Analyze the list of formal parameters.
1536
1571
args = list (itertools .chain (called .args .posonlyargs or (), called .args .args ))
0 commit comments