-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Conditional function variants result in warning despite having identical types (only varying in parameter names) #10575
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
Comments
Additionally, the cause of this error is not very discoverable. The error message doesn't tell you what the difference is, just that there is one. The documentation doesn't seem to cover this case. The only information I could find about what is happening here is this ticket itself. |
Fix `All conditional function variants must have identical signatures`, see python/mypy#10575.
Ok, I'll play devil's advocate. What should mypy do if you write: try:
from math import comb
except ImportError:
def comb(n: int, k: int) -> int: # All conditional function variants must have identical signatures
return int(factorial(n) / factorial(k) / factorial(n - k)) And then call: comb(n = 3, k = 5) I agree that the error should be more descriptive. My question is: is this a bug? If the above situation comes up, what should happen? Should an error only be produced here? That seems like it would make type tracking much more painful. |
Fix `All conditional function variants must have identical signatures`, see python/mypy#10575.
These both result in the
All conditional function variants must have identical signatures
warning:Typeshed conditionally defines
math.comb
asdef comb(__n: int, __k: int) -> int: ...
. Changing the parameter names in either of the above examples to match the typeshed signature silences the warning:I think this came up before in #1168 (and via #1801, but, given the above, I don't think #698 addresses this).
The text was updated successfully, but these errors were encountered: