Open PIG208 opened 2 years ago
So to be clear, the issue is that mypy should be looking for a common supertype of the two parameter specifications, and using that common supertype to solve the parameter-specification variable.
Given the two parameter specifications:
(x: int, y: str)
(y: int, x: str)
Mypy should be able to recognise that these two parameter specifications have a common "supertype". Using PEP-570 syntax, it would be something like:
(x: int, y: str, /)
And mypy should use that "common supertype" to solve the parameter-specification variable, rather than emitting an error. This means that the inferred return type of the call foo(x_y, y_x)
in your example should be something like (x: int, y: str, /) -> bool
.
Did I get that right?
Yes, that's correct.
Bug Report
When two callables have a conflicting positional-or-keyword parameter, Mypy gives an error even though they have the same behavioral supertype.
To Reproduce
The example is taken from the PEP.
Expected Behavior
Note that
Still, at least there should be no false positives here.
Actual Behavior
Argument 1 to "foo" has incompatible type "Callable[[Arg(int, 'x'), Arg(str, 'y')], int]"; expected "Callable[[Arg(int, 'y'), Arg(str, 'x')], int]"
Your Environment