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
{{ message }}
Repository navigation
Bad error message for arguments between ParamSpec P.args and P.kwargs #13966
With ParamSpec, you are not allowed to define parameters between *args and **kwargs. PEP 612 is very clear on this point:
Placing keyword-only parameters between the *args and **kwargs is forbidden.
Mypy's error message in this case should probably be improved to indicate as such.
If you move the parameters backend and backend_options before *args, it will type check without errors. That assumes you want backend and backend_options to be positional + keyword parameters and not keyword-only parameters. There's no way to combine ParamSpec with keyword-only parameters because of the constraint I mentioned above.
changed the title [-]ParamSpec P.args and P.kwargs are not defined when using explicit keyword argument[/-][+]Bad error message for arguments between ParamSpec P.args and P.kwargs[/+]on Nov 13, 2023
Activity
erictraut commentedon Oct 30, 2022
With
ParamSpec, you are not allowed to define parameters between*argsand**kwargs. PEP 612 is very clear on this point:Mypy's error message in this case should probably be improved to indicate as such.
If you move the parameters
backendandbackend_optionsbefore*args, it will type check without errors. That assumes you wantbackendandbackend_optionsto be positional + keyword parameters and not keyword-only parameters. There's no way to combineParamSpecwith keyword-only parameters because of the constraint I mentioned above.hauntsaninja commentedon Oct 31, 2022
mypy 0.990 will have a less atrocious error message here (but definitely could still be made more helpful)
Add another invalid ParamSpec test case
Add another invalid ParamSpec test case (#13968)
ilevkivskyi commentedon Aug 16, 2023
Yeah, the error message is still not very good:
[-]ParamSpec P.args and P.kwargs are not defined when using explicit keyword argument[/-][+]Bad error message for arguments between ParamSpec P.args and P.kwargs[/+]Reject invalid ParamSpec locations (python#18278)