Skip to content

Commit 93bc08c

Browse files
Allow arbitrary types dict.pop (3 overloads)
1 parent b974642 commit 93bc08c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

stdlib/builtins.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,8 @@ class dict(MutableMapping[_KT, _VT]):
12281228
@overload
12291229
def pop(self, key: object, /) -> _VT: ...
12301230
@overload
1231+
def pop(self, key: object, default: _VT, /) -> _VT: ...
1232+
@overload
12311233
def pop(self, key: object, default: _T, /) -> _VT | _T: ...
12321234
def __len__(self) -> int: ...
12331235
def __getitem__(self, key: _KT, /) -> _VT: ...

stdlib/typing.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ class MutableMapping(Mapping[_KT, _VT]):
794794
@overload
795795
def pop(self, key: Any, /) -> _VT: ...
796796
@overload
797+
def pop(self, key: Any, default: _VT, /) -> _VT: ...
798+
@overload
797799
def pop(self, key: Any, default: _T, /) -> _VT | _T: ...
798800
def popitem(self) -> tuple[_KT, _VT]: ...
799801
# This overload should be allowed only if the value type is compatible with None.

0 commit comments

Comments
 (0)