Following code:
class A(TypedDict):
abc: str
class B(TypedDict):
xyz: str
def func(dict_class: Union[type[A], type[B]]) -> None:
print(dict_class.__annotations__)
func(A)
results in a following MyPy error:
error: Argument 1 to "func" has incompatible type "Type[A]"; expected "Union[Type[A], Type[B]]"
Is there any other way to tell MyPy that the dict_class argument can only be of specified typed dicts types? I know that I can change the type hints to something more generic so that the MyPy won't complain but I really wouldn't want to.
What's more important is that the PyCharm IDE seems to work with this example all right. Is it a MyPy bug then?