-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
typing of callables falls away in dicts, without warnings.
To Reproduce
from typing import Callable, Any, Mapping
def api(handlers: Mapping[Any, Callable[[str], int]]) -> None:
pass
def handler1(arg):
return 1
def handler2(arg:int) -> str:
return "foo"
handlers = {
1: handler1,
2: handler2
}
api(handlers) # no error
api(handlers={1:handler1, 2:handler2}) # Mypy correctly identifes handler2 as not matching the spec.
Expected Behavior
Running MyPy --strict
on the above file should somehow warn us that the type of handler2
is being recast as a
callable taking Any
Actual Behavior
MyPy approves this file, even though an incorrect type is being passed in as a handler via the dict.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong