Open
Description
Bug Report
mypy does not flag an error when attempting to pass keyword args=
to a function that takes *args
, even though that is entirely nonsensical.
To Reproduce
def foo(*args: str) -> tuple[str, ...]:
return args
print(foo(args="a"))
This code throws TypeError: foo() got an unexpected keyword argument 'args'
when run.
Expected Behavior
mypy should flag this as an error, as the code throws a TypeError
at runtime.
Actual Behavior
mypy reports no errors, even on --strict
: Success: no issues found in 1 source file
. mypy will attempt to typecheck the argument passed as args=
according to the type of args
in the function signature, even though passing the argument this way is completely illegal.
Your Environment
- Mypy version used: mypy 1.15.0 (compiled: yes)
- Mypy command-line flags: --strict
- Mypy configuration options from
mypy.ini
(and other config files): (none) - Python version used:
Python 3.10.11 (v3.10.11:7d4cc5aa85, Apr 4 2023, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin