mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
WIP: Mapping.{get,pop} can return default type (#223)
* Mapping.{get,pop} can return default type
* Mapping values are covariant
This commit is contained in:
committed by
Guido van Rossum
parent
5b5f01f33c
commit
d43adbe97e
@@ -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
|
||||
SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView, ByteString, Optional,
|
||||
)
|
||||
from abc import abstractmethod, ABCMeta
|
||||
|
||||
@@ -507,8 +507,14 @@ 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]: ...
|
||||
def get(self, k: _KT, default: _VT = None) -> _VT: ...
|
||||
def pop(self, k: _KT, default: _VT = None) -> _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 popitem(self) -> Tuple[_KT, _VT]: ...
|
||||
def setdefault(self, k: _KT, default: _VT = None) -> _VT: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user