-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
Consider the following snippet:
Foo = NewType('Foo', int)
Bar = NewType('Bar', str)
Baz = NewType('Baz', str)
def things(thing_1: Bar, thing_2: Bar) -> Baz:
return Baz(thing_1 + thing_2)
stuff: Dict[Foo, Callable[[Bar, Bar], Bar]] = {
Foo(1): things
}
it = stuff.get(Foo(1))
result = things(Bar('test'), Bar('strings'))
The result of running mypy is this:
foo.py:11: error: Dict entry 0 has incompatible type "Foo":
This message is a bit misleading (possibly truncated?); the issue here is with the mismatch in return type between lines 7 and 11 (Bar vs. Baz), not with the type of the key in the dictionary.
Metadata
Metadata
Assignees
Labels
No labels