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
https://mypy-play.net/?flags=verbose%2Cstrict&mypy=latest&python=3.12&gist=4e82d2194b167b990da83b77b26bfdf9
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
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
https://mypy-play.net/?flags=verbose%2Cstrict&mypy=latest&python=3.12&gist=4e82d2194b167b990da83b77b26bfdf9
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
TypeErrorat 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 asargs=according to the type ofargsin the function signature, even though passing the argument this way is completely illegal.Your Environment
mypy.ini(and other config files): (none)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