I'm tring to declare type of following function parameter with typing
module:
import typing
class A(object):
pass
class B(A):
pass
class C(B):
pass
def my_func(p: typing.Dict[A, str]) -> None:
pass
my_func({C: 'foo'})
p
parameter of my_func
must be dict
with childclass of A
as key and str
as value. Actual notation fail with mypy
check:
example.py:17: error: List item 0 has incompatible type "Tuple[C, str]"
How to declare type of p
with typing ?