-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
python/typeshed
#14593Closed
Copy link
Labels
bugmypy got something wrongmypy got something wrong
Description
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.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong