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
Mypy gives this error message for the decorator line (which has correct kwargs, but in an order different from __init__):
Argument 1 has incompatible type "type[SomeClass]"; expected "Callable[[str, int, float], SomeClass]" [arg-type]
This seems clearly wrong; all the arguments to smoke_testable were kwargs, and their order should not matter. If I change the order in smoke_testable to the same as __init__, there is no error (line 2).
The third line should give an error (because it assigns an int to a str kwarg and a str to an int kwarg), and it does. However, the error message is surprising:
Argument 1 has incompatible type "type[SomeClass]"; expected "Callable[[int, str, float], SomeClass]"
As far as I can tell, the class is a Callable[[int, str, float], SomeClass].
Expected Behavior
The first decorator line should produce no error (it currently does).
The second decorator line should produce no error, and it currently does not.
The third decorator line should produce an error, but the error message should not claim that SomeClass is not Callable[[int, str, float], SomeClass].
Your Environment
Mypy version used: 1.6.1
Mypy command-line flags: --strict
Python version used: 3.11
The text was updated successfully, but these errors were encountered:
Fixes#16405Fixes#16412
Imprecise argument kinds inference was added a while ago to support
various edge cases with `ParamSpec`. This feature required mapping
actual kinds to formal kinds, which is in general undecidable. At that
time we decided to not add much special-casing, and wait for some real
use-cases. So far there are two relevant issues, and it looks like both
of them can be fixed with simple special-casing: ignore argument
positions in subtyping if arguments can be matched by name. This adds
minor unsafety, and generally doesn't look bad, so I think we should go
ahead with it.
---------
Co-authored-by: Alex Waygood <[email protected]>
Fixes#16405Fixes#16412
Imprecise argument kinds inference was added a while ago to support
various edge cases with `ParamSpec`. This feature required mapping
actual kinds to formal kinds, which is in general undecidable. At that
time we decided to not add much special-casing, and wait for some real
use-cases. So far there are two relevant issues, and it looks like both
of them can be fixed with simple special-casing: ignore argument
positions in subtyping if arguments can be matched by name. This adds
minor unsafety, and generally doesn't look bad, so I think we should go
ahead with it.
---------
Co-authored-by: Alex Waygood <[email protected]>
Consider this code (playground)
Mypy gives this error message for the decorator line (which has correct kwargs, but in an order different from
__init__
):Argument 1 has incompatible type "type[SomeClass]"; expected "Callable[[str, int, float], SomeClass]" [arg-type]
This seems clearly wrong; all the arguments to
smoke_testable
were kwargs, and their order should not matter. If I change the order in smoke_testable to the same as__init__
, there is no error (line 2).The third line should give an error (because it assigns an int to a str kwarg and a str to an int kwarg), and it does. However, the error message is surprising:
Argument 1 has incompatible type "type[SomeClass]"; expected "Callable[[int, str, float], SomeClass]"
As far as I can tell, the class is a
Callable[[int, str, float], SomeClass]
.Expected Behavior
The first decorator line should produce no error (it currently does).
The second decorator line should produce no error, and it currently does not.
The third decorator line should produce an error, but the error message should not claim that
SomeClass
is notCallable[[int, str, float], SomeClass]
.Your Environment
The text was updated successfully, but these errors were encountered: