@@ -377,6 +377,11 @@ def _missing_member_hint(
377
377
"Used when a slice step is 0 and the object doesn't implement "
378
378
"a custom __getitem__ method." ,
379
379
),
380
+ "E1145" : (
381
+ "Too few positional arguments for %s call" ,
382
+ "too-few-function-args" ,
383
+ "Used when a function or method call has fewer arguments than expected." ,
384
+ ),
380
385
"W1113" : (
381
386
"Keyword argument before variable positional arguments list "
382
387
"in the definition of %s function" ,
@@ -1419,9 +1424,22 @@ def _check_argument_order(
1419
1424
if calling_parg_names != called_param_names [: len (calling_parg_names )]:
1420
1425
self .add_message ("arguments-out-of-order" , node = node , args = ())
1421
1426
1422
- def _check_isinstance_args (self , node : nodes .Call ) -> None :
1423
- if len (node .args ) != 2 :
1424
- # isinstance called with wrong number of args
1427
+ def _check_isinstance_args (self , node : nodes .Call , callable_name : str ) -> None :
1428
+ if len (node .args ) > 2 :
1429
+ # for when isinstance called with too many args
1430
+ self .add_message (
1431
+ "too-many-function-args" ,
1432
+ node = node ,
1433
+ args = (callable_name ,),
1434
+ confidence = HIGH ,
1435
+ )
1436
+ elif len (node .args ) < 2 :
1437
+ self .add_message (
1438
+ "too-few-function-args" ,
1439
+ node = node ,
1440
+ args = (callable_name ,),
1441
+ confidence = HIGH ,
1442
+ )
1425
1443
return
1426
1444
1427
1445
second_arg = node .args [1 ]
@@ -1451,7 +1469,7 @@ def visit_call(self, node: nodes.Call) -> None:
1451
1469
if called .args .args is None :
1452
1470
if called .name == "isinstance" :
1453
1471
# Verify whether second argument of isinstance is a valid type
1454
- self ._check_isinstance_args (node )
1472
+ self ._check_isinstance_args (node , callable_name )
1455
1473
# Built-in functions have no argument information.
1456
1474
return
1457
1475
@@ -1554,7 +1572,9 @@ def visit_call(self, node: nodes.Call) -> None:
1554
1572
elif not overload_function :
1555
1573
# Too many positional arguments.
1556
1574
self .add_message (
1557
- "too-many-function-args" , node = node , args = (callable_name ,)
1575
+ "too-many-function-args" ,
1576
+ node = node ,
1577
+ args = (callable_name ,),
1558
1578
)
1559
1579
break
1560
1580
0 commit comments