mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +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:
@@ -4,7 +4,7 @@ from typing import (
|
||||
TypeVar, Iterator, Iterable, overload,
|
||||
Sequence, MutableSequence, Mapping, MutableMapping, Tuple, List, Any, Dict, Callable, Generic,
|
||||
Set, AbstractSet, MutableSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsBytes,
|
||||
SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView, ByteString, Optional,
|
||||
SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView, ByteString
|
||||
)
|
||||
from abc import abstractmethod, ABCMeta
|
||||
|
||||
@@ -507,14 +507,8 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def copy(self) -> Dict[_KT, _VT]: ...
|
||||
@overload
|
||||
def get(self, k: _KT) -> Optional[_VT]: ...
|
||||
@overload
|
||||
def get(self, k: _KT, default: _T) -> Union[_VT, _T]: ...
|
||||
@overload
|
||||
def pop(self, k: _KT) -> _VT: ...
|
||||
@overload
|
||||
def pop(self, k: _KT, default: _T) -> Union[_VT, _T]: ...
|
||||
def get(self, k: _KT, default: _VT = None) -> _VT: ...
|
||||
def pop(self, k: _KT, default: _VT = None) -> _VT: ...
|
||||
def popitem(self) -> Tuple[_KT, _VT]: ...
|
||||
def setdefault(self, k: _KT, default: _VT = None) -> _VT: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user