-
Notifications
You must be signed in to change notification settings - Fork 281
Closed as duplicate of#2470
Copy link
Labels
Description
Describe the Bug
available_clients = {}
def process_device(source, device):
available_clients.setdefault(device.machineIdentifier, {"device": device}) # makes the value type dict | None
available_clients[device.machineIdentifier].setdefault("source", source) # error!The standard library type annotation on MutableMapping.setdefault weird here
class MutableMapping:
# This overload should be allowed only if the value type is compatible with None.
#
# Keep the following methods in line with MutableMapping.setdefault, modulo positional-only differences:
# -- collections.OrderedDict.setdefault
# -- collections.ChainMap.setdefault
# -- weakref.WeakKeyDictionary.setdefault
@overload
def setdefault(self: MutableMapping[_KT, _T | None], key: _KT, default: None = None, /) -> _T | None: ...
@overload
def setdefault(self, key: _KT, default: _VT, /) -> _VT: ...I think maybe overload evaluation is pinning the type too early based on the first overload, even when it was not selected.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Reactions are currently unavailable