@@ -377,6 +377,11 @@ def _missing_member_hint(
377377 "Used when a slice step is 0 and the object doesn't implement "
378378 "a custom __getitem__ method." ,
379379 ),
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+ ),
380385 "W1113" : (
381386 "Keyword argument before variable positional arguments list "
382387 "in the definition of %s function" ,
@@ -1419,9 +1424,22 @@ def _check_argument_order(
14191424 if calling_parg_names != called_param_names [: len (calling_parg_names )]:
14201425 self .add_message ("arguments-out-of-order" , node = node , args = ())
14211426
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+ )
14251443 return
14261444
14271445 second_arg = node .args [1 ]
@@ -1451,7 +1469,7 @@ def visit_call(self, node: nodes.Call) -> None:
14511469 if called .args .args is None :
14521470 if called .name == "isinstance" :
14531471 # Verify whether second argument of isinstance is a valid type
1454- self ._check_isinstance_args (node )
1472+ self ._check_isinstance_args (node , callable_name )
14551473 # Built-in functions have no argument information.
14561474 return
14571475
@@ -1554,7 +1572,9 @@ def visit_call(self, node: nodes.Call) -> None:
15541572 elif not overload_function :
15551573 # Too many positional arguments.
15561574 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 ,),
15581578 )
15591579 break
15601580
0 commit comments