mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-25 21:31:09 +08:00
Revert "WIP: Mapping.{get,pop} can return default type (#223)"
This reverts commit d43adbe97e.
Here's a simple example of code that breaks with this PR:
from typing import Mapping, Dict, Tuple
a = {('0', '0'): 42} # type: Mapping[Tuple[str, str], int]
b = a.get(('1', '1'), 0)
This gives an error on the last line:
error: No overload variant of "get" of "dict" matches argument types [Tuple[builtins.str, builtins.str], builtins.int]
This commit is contained in:
@@ -157,20 +157,17 @@ class MutableSet(AbstractSet[_T], Generic[_T]):
|
||||
def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...
|
||||
def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
|
||||
|
||||
class Mapping(Sized, Iterable[_KT], Container[_KT], Generic[_KT, _VT_co]):
|
||||
class Mapping(Sized, Iterable[_KT], Container[_KT], Generic[_KT, _VT]):
|
||||
@abstractmethod
|
||||
def __getitem__(self, k: _KT) -> _VT_co: ...
|
||||
def __getitem__(self, k: _KT) -> _VT: ...
|
||||
# Mixin methods
|
||||
@overload
|
||||
def get(self, k: _KT) -> Optional[_VT_co]: ...
|
||||
@overload
|
||||
def get(self, k: _KT, default: _T) -> Union[_VT_co, _T]: ...
|
||||
def get(self, k: _KT, default: _VT = ...) -> _VT: ...
|
||||
def keys(self) -> list[_KT]: ...
|
||||
def values(self) -> list[_VT_co]: ...
|
||||
def items(self) -> list[Tuple[_KT, _VT_co]]: ...
|
||||
def values(self) -> list[_VT]: ...
|
||||
def items(self) -> list[Tuple[_KT, _VT]]: ...
|
||||
def iterkeys(self) -> Iterator[_KT]: ...
|
||||
def itervalues(self) -> Iterator[_VT_co]: ...
|
||||
def iteritems(self) -> Iterator[Tuple[_KT, _VT_co]]: ...
|
||||
def itervalues(self) -> Iterator[_VT]: ...
|
||||
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
|
||||
def __contains__(self, o: object) -> bool: ...
|
||||
|
||||
class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
@@ -180,10 +177,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __delitem__(self, v: _KT) -> None: ...
|
||||
|
||||
def clear(self) -> None: ...
|
||||
@overload
|
||||
def pop(self, k: _KT) -> _VT: ...
|
||||
@overload
|
||||
def pop(self, k: _KT, default: _T) -> Union[_VT, _T]: ...
|
||||
def pop(self, k: _KT, default: _VT = ...) -> _VT: ...
|
||||
def popitem(self) -> Tuple[_KT, _VT]: ...
|
||||
def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user