The assignment g = wrap(_g) fails with Argument 1 to "wrap" has incompatible type "Callable[[Dervied, int], int]"; expected "Callable[[Base, int], int]". I would have expected both ways of wrapping a function to be the same (ans as far as I can tell they do so at runtime) and therefore both should be allowed.
This is also not a general issue with assignments as the following code type checks:
Note that mypy-play seems to use c660354 rather than the latest commit from master for some reason. The output on current master is slightly different (the type of C.abc is no longer consider def (self: __main__.A, a: builtins.int) -> builtins.int):
test_assign_function_subclass.py:32: error: Incompatible types in assignment (expression has type "Callable[[C, int], int]", base class "A" defined the type as "Callable[[A, int], int]") [assignment]
test_assign_function_subclass.py:50: error: Cannot determine type of "abc" [has-type]
test_assign_function_subclass.py:55: note: Revealed type is "def (self: test_assign_function_subclass.A, a: builtins.int) -> builtins.int"
test_assign_function_subclass.py:56: note: Revealed type is "def (self: test_assign_function_subclass.B, a: builtins.int) -> builtins.int"
test_assign_function_subclass.py:57: error: Cannot determine type of "abc" [has-type]
test_assign_function_subclass.py:57: note: Revealed type is "Any"
test_assign_function_subclass.py:58: note: Revealed type is "def (self: test_assign_function_subclass.D, a: builtins.int) -> builtins.int"
test_assign_function_subclass.py:59: note: Revealed type is "def (self: test_assign_function_subclass.E, a: builtins.int) -> builtins.int"
Found 3 errors in 1 file (checked 1 source file)
Expected Behavior
No error, code type checks
Actual Behavior
main.py:32: error: Argument 1 to "wrap" has incompatible type "Callable[[C, int], int]"; expected "Callable[[A, int], int]" [arg-type]
Activity