File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2361,8 +2361,9 @@ def _detect_missing_positional_arg(
23612361 """Try to identify a single missing positional argument using type alignment.
23622362
23632363 If the caller and callee are just positional arguments and exactly one arg is missing,
2364- we scan left to right to find which argument skipped. If there is an error, report it
2365- and return True, or return False to fall back to normal checking.
2364+ we scan left to right to find which argument skipped. If only the last argument is missing,
2365+ we return False since it's already handled in a desired manner. If there is an error,
2366+ report it and return True, or return False to fall back to normal checking.
23662367 """
23672368 if not all (k == ARG_POS for k in callee .arg_kinds ):
23682369 return False
@@ -2387,6 +2388,9 @@ def _detect_missing_positional_arg(
23872388 if skip_idx is None or j != len (arg_types ):
23882389 return False
23892390
2391+ if skip_idx == len (callee .arg_types ) - 1 :
2392+ return False
2393+
23902394 param_name = callee .arg_names [skip_idx ]
23912395 callee_name = callable_name (callee )
23922396 if param_name is None or callee_name is None :
Original file line number Diff line number Diff line change @@ -3793,6 +3793,22 @@ main:3: error: Missing positional argument "z" in call to "f"
37933793main:3: error: Argument 1 to "f" has incompatible type "str"; expected "int"
37943794main:3: error: Argument 2 to "f" has incompatible type "int"; expected "str"
37953795
3796+ [case testMissingPositionalArgNoShiftPatternLast]
3797+ def f(x: int, y: str, z: bytes) -> None: ...
3798+
3799+ f(123, "wrong")
3800+ [builtins fixtures/primitives.pyi]
3801+ [out]
3802+ main:3: error: Missing positional argument "z" in call to "f"
3803+
3804+ [case testMissingPositionalArgNoShiftPatternNone]
3805+ def f(x: int) -> None: ...
3806+
3807+ f()
3808+ [builtins fixtures/primitives.pyi]
3809+ [out]
3810+ main:3: error: Missing positional argument "x" in call to "f"
3811+
37963812[case testMissingPositionalArgMultipleMissing]
37973813def f(a: int, b: str, c: float, d: list[int]) -> None: ...
37983814
You can’t perform that action at this time.
0 commit comments