@@ -3814,9 +3814,9 @@ f(1, b'x', 1)
38143814main:3: error: Missing positional argument "y" in call to "f"
38153815
38163816[case testMissingPositionalArgShiftDetectedFirst]
3817- def f(x: int, y: str, z: bytes) -> None: ...
3817+ def f(x: int, y: str, z: bytes, last: float ) -> None: ...
38183818
3819- f("hello", b'x')
3819+ f("hello", b'x', 1.5 )
38203820[builtins fixtures/primitives.pyi]
38213821[out]
38223822main:3: error: Missing positional argument "x" in call to "f"
@@ -3891,3 +3891,46 @@ f("hello", b'x')
38913891main:3: error: Missing positional argument "z" in call to "f"
38923892main:3: error: Argument 1 to "f" has incompatible type "str"; expected "int"
38933893main:3: error: Argument 2 to "f" has incompatible type "bytes"; expected "str"
3894+
3895+ [case testMissingPositionalArgNamesHigherN]
3896+ # See https://github.com/python/mypy/issues/21427
3897+ def convert2(first: int, second: str) -> None: ...
3898+
3899+ # Possibly omitted arg, but we still issue two errors because there is only one argument
3900+ convert2("hello") # E: Missing positional argument "second" in call to "convert2" \
3901+ # E: Argument 1 to "convert2" has incompatible type "str"; expected "int"
3902+
3903+ # Other cases
3904+ convert2() # E: Missing positional arguments "first", "second" in call to "convert2"
3905+
3906+ convert2("hello", 1) # E: Argument 1 to "convert2" has incompatible type "str"; expected "int" \
3907+ # E: Argument 2 to "convert2" has incompatible type "int"; expected "str"
3908+
3909+ def convert3(first: int, second: str, third: float) -> None: ...
3910+
3911+ # Possibly omitted arg, but we now only issue one error
3912+ convert3("hello", 3.15) # E: Missing positional argument "first" in call to "convert3"
3913+
3914+ # Other cases
3915+ convert3("hello") # E: Missing positional arguments "second", "third" in call to "convert3" \
3916+ # E: Argument 1 to "convert3" has incompatible type "str"; expected "int"
3917+
3918+ convert3(3.15, "hello") # E: Missing positional argument "third" in call to "convert3" \
3919+ # E: Argument 1 to "convert3" has incompatible type "float"; expected "int"
3920+
3921+ def convert4(first: int, second: str, third: float, fourth: bytes) -> None: ...
3922+
3923+ # Possibly omitted arg, but we now only issue one error
3924+ convert4("hello", 3.15, b'') # E: Missing positional argument "first" in call to "convert4"
3925+
3926+ # Other cases
3927+ convert4("hello") # E: Missing positional arguments "second", "third", "fourth" in call to "convert4" \
3928+ # E: Argument 1 to "convert4" has incompatible type "str"; expected "int"
3929+
3930+ convert4("hello", 3.15) # E: Missing positional arguments "third", "fourth" in call to "convert4" \
3931+ # E: Argument 1 to "convert4" has incompatible type "str"; expected "int" \
3932+ # E: Argument 2 to "convert4" has incompatible type "float"; expected "str"
3933+
3934+ convert4(b'', "hello", 3.15) # E: Missing positional argument "fourth" in call to "convert4" \
3935+ # E: Argument 1 to "convert4" has incompatible type "bytes"; expected "int"
3936+ [builtins fixtures/primitives.pyi]
0 commit comments