-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too many arguments with specific argument after *args #14648
Comments
This is similar to #9710, however, mypy is not entirely incorrect. This simple example would "type check" but blow up at runtime if def foo(x: int, y: int, z: int):
pass
def bar(*a: int):
foo(*a, 0)
bar(1, 2, 3) # => foo(1, 2, 3, 0) => too many arguments! I suppose this goes the other way too. The error message should probably be tweaked to say |
The issue I have with this is that mypy won't complain if we just omit the specific argument or use it at the beginning. def foo(x: int, y: int, z: int):
pass
def bar(*a: int):
foo(*a) and def foo(x: int, y: int, z: int):
pass
def bar(*a: int):
foo(0, *a) will type check successfully. |
Yea, I don't know what's up with that. I'd guess that is either an oversight or an explicit design choice to avoid technically-correct-but-low-value-relative-to-noise type errors. |
Almost equally simple reduced example (playground): def SomeFun(a, b):
pass
SomeFun(*[1], 2)
|
Bug Report
When using specific arguments after providing arguments with
*args
, mypy will report an error.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=f8b653e4348ebc7a4006c2a126ed0d85
Expected Behavior
Mypy should succeed.
Actual Behavior
Your Environment
See playground
The text was updated successfully, but these errors were encountered: