You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report
You can pass **kwargs or *args to a function, even if all of its arguments are already passed. I would expect this to raise an error, since it's only valid for empty kwargs and args.
Expected Behavior
In both g and h, the x argument is specified, so I would expecting passing **kwargs or *args to produce an error, since they can never correctly pass additional arguments.
Actual Behavior
Success: no issues found in 1 source file
Your Environment
I tried several versions of mypy (including 1.16.0 and master) with python3.12 in mypy playground.
I tried with both with and without --check-untyped-defs
This wording is almost the same as the message of the corresponding RuntimeError, so I think it's good enough.
This behavior is a bit inconsistent, though, your FR to reject calls where all args are present together with vararg sounds good! In both cases the only case when unpacking is valid is an empty arg/kwarg, so rejecting such calls would be helpful.
Thanks @erictraut, the proposed "allow any set of arguments that could potentially succeed at runtime EXCEPT if the only potential argument-to-parameter mappings involve unpacking empty arguments" approach sounds like the behavior that I expected.
Bug Report
You can pass
**kwargs
or*args
to a function, even if all of its arguments are already passed. I would expect this to raise an error, since it's only valid for emptykwargs
andargs
.To Reproduce
playground link
Expected Behavior
In both
g
andh
, thex
argument is specified, so I would expecting passing**kwargs
or*args
to produce an error, since they can never correctly pass additional arguments.Actual Behavior
Your Environment
I tried several versions of mypy (including 1.16.0 and
master
) with python3.12 in mypy playground.I tried with both with and without
--check-untyped-defs
** Related Issues
*args
and**kwargs
are allowed even to methods with no arguments #13380 (that issue specifically mentions functions with no arguments)The text was updated successfully, but these errors were encountered: