-
-
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
mypy 1.7.0, ParamSpec: Cannot infer type argument 1 of "function_name"
when using keyword arguments.
#16485
Comments
Cannot infer type argument 1 of "function_name"
when using keyword arguments.
Fixes #16485 My initial implementation of imprecise constraints fallback was really fragile and ad-hoc, and I now see several edge case scenarios where we may end up using imprecise constraints for a `ParamSpec` while some precise ones are available. So I re-organized it: now we just infer everything as normally, and filter out imprecise (if needed) at the very end, when we have the full picture. I also fix an accidental omission in `expand_type()`.
@ilevkivskyi @orsinium parametrize(_test, Case(1, 2), Case(3, b=4)) # error: Cannot infer type argument 1 of "parametrize" [misc]
parametrize(_test, Case("1", "2")) # error: Cannot infer type argument 1 of "parametrize" |
Confirming, the issue is still here on 1.7.1. @ilevkivskyi could you re-open the issue, please? I can't re-open it, I can only make a new one. |
@orsinium could you please open a new one? |
Open a new one and get a ban for spamming. Can you make at least some effort, or you can only complain? |
What effort do you want? Contribute to fix a bug? |
Sorry for this noise. |
Bug Report
The issues with ParamSpec inference for pytypest first appeared in mypy 1.6.0, see #16301. In 1.7.0, it was fixed for some cases but not all.
This specific issue happens when a function accepts multiple classes using ParamSpec and some of them pass an argument as keyword one and some pass the same argument as a positional one.
To Reproduce
Expected Behavior
It shouldn't matter how an argument is passed into ParamSpec. If it can be passed into the target function described by the ParamSpec, it should pass type checking.
Actual Behavior
For the last line of the code:
The same happens if instead of
*cases: Case[P]
the function acceptscase1: Case[P], case2: Case[P]
.Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: