Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix sorteddict stubs
Browse files Browse the repository at this point in the history
Mypy now includes python/typeshed#6653
which triggered

```
stubs/sortedcontainers/sorteddict.pyi:88: error: Signature of "update" incompatible with supertype "MutableMapping"  [override]
stubs/sortedcontainers/sorteddict.pyi:88: note:      Superclass:
stubs/sortedcontainers/sorteddict.pyi:88: note:          @overload
stubs/sortedcontainers/sorteddict.pyi:88: note:          def update(self, SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None
stubs/sortedcontainers/sorteddict.pyi:88: note:          @overload
stubs/sortedcontainers/sorteddict.pyi:88: note:          def update(self, Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None
stubs/sortedcontainers/sorteddict.pyi:88: note:          @overload
stubs/sortedcontainers/sorteddict.pyi:88: note:          def update(self, **kwargs: _VT) -> None
stubs/sortedcontainers/sorteddict.pyi:88: note:      Subclass:
stubs/sortedcontainers/sorteddict.pyi:88: note:          @overload
stubs/sortedcontainers/sorteddict.pyi:88: note:          def update(self, Mapping[_KT, _VT], **kwargs: _VT) -> None
stubs/sortedcontainers/sorteddict.pyi:88: note:          @overload
stubs/sortedcontainers/sorteddict.pyi:88: note:          def update(self, Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None
stubs/sortedcontainers/sorteddict.pyi:88: note:          @overload
stubs/sortedcontainers/sorteddict.pyi:88: note:          def update(self, **kwargs: _VT) -> None
```
  • Loading branch information
David Robertson committed May 6, 2022
1 parent 227e4cb commit e1993b4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions stubs/sortedcontainers/sorteddict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,19 @@ class SortedDict(Dict[_KT, _VT]):
def popitem(self, index: int = ...) -> Tuple[_KT, _VT]: ...
def peekitem(self, index: int = ...) -> Tuple[_KT, _VT]: ...
def setdefault(self, key: _KT, default: Optional[_VT] = ...) -> _VT: ...
@overload
def update(self, __map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def update(self, __iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
@overload
def update(self, **kwargs: _VT) -> None: ...
# Mypy now reports the first overload as an error, because typeshed widened the type
# of `__map` to its internal `_typeshed.SupportsKeysAndGetItem` type in
# https://github.com/python/typeshed/pull/6653
# Since sorteddicts don't change the signature of `update` from that of `dict`, we
# let the stubs for `update` inherit from the stubs for `dict`. (I suspect we could
# do the same for many othe methods.) We leave the stubs commented to better track
# how this file has evolved from the original stubs.
# @overload
# def update(self, __map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
# @overload
# def update(self, __iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
# @overload
# def update(self, **kwargs: _VT) -> None: ...
def __reduce__(
self,
) -> Tuple[
Expand Down

0 comments on commit e1993b4

Please sign in to comment.