async def psubscribe(self, *args: ChannelT, **kwargs: PubSubHandler):
new_patterns: Dict[ChannelT, Optional[PubSubHandler]] = dict.fromkeys(args)
new_patterns.update(kwargs)
This code (taken from aioredis) produces this error:
error: Argument 1 to "update" of "dict" has incompatible type "Dict[str, Callable[[Dict[str, str]], None]]"; expected "Mapping[Union[bytes, str, memoryview], Optional[Callable[[Dict[str, str]], None]]]" [arg-type]
But, the types are compatible as the keys and values are part of the expected union, I can't think of any operation that would make this unsafe. I understand it could be unsafe if the expectation was MutableMapping, as the function might assign any of the unioned types, but for Mapping this looks completely safe to me.
This code (taken from aioredis) produces this error:
error: Argument 1 to "update" of "dict" has incompatible type "Dict[str, Callable[[Dict[str, str]], None]]"; expected "Mapping[Union[bytes, str, memoryview], Optional[Callable[[Dict[str, str]], None]]]" [arg-type]But, the types are compatible as the keys and values are part of the expected union, I can't think of any operation that would make this unsafe. I understand it could be unsafe if the expectation was
MutableMapping, as the function might assign any of the unioned types, but forMappingthis looks completely safe to me.