A
and B
are sub-classes of Sup
. These functions are defined:
def get_A_report(a: A) -> int
def get_B_report(b: B) -> int
What are the correct typing hints for f
?
f = {
A: get_A_report,
B: get_B_report,
}
Note: the naive:
f: Dict[Type[Sup],Callable[[Sup],int]]
results in this error:
error: Dict entry 0 has incompatible type
error: Dict entry 1 has incompatible type
I tried to use TypeVar
and Protocol
, with no success.
Dict entry 0 has incompatible type
2