Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Closed
Copy link
Description
Typeshed annotates collections.ChainMap as:
classChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]): maps: list[Mapping[_KT, _VT]] def__init__(self, *maps: Mapping[_KT, _VT]) ->None: ... defnew_child(self: Self, m: Mapping[_KT, _VT] |None= ...) ->Self: ...The self.maps attribute holds the chained mappings. It should be annotated as list[MutableMapping[_KT, _VT]].
The *maps parameter of __init__ and the m parameter of new_child need to be MutableMapping[_KT, _VT] as well.
As it is, the implementation in the standard library violates the type hint for self.maps in its __setitem__ method:
def__setitem__(self, key, value): self.maps[0][key] =valueMetadata
Metadata
Assignees
Labels
No labels