Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ class SupportsTrunc(Protocol):

# Mapping-like protocols

# The second and third overload could technically be combined, but splitting
# them works better with some type checkers.
class SupportsGet(Protocol[_KT_contra, _VT_co]): # type: ignore[misc] # Covariant type as parameter
@overload
def get(self, key: _KT_contra, /) -> _VT_co | None: ...
@overload
def get(
self, key: _KT_contra, default: _VT_co, / # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
) -> _VT_co: ...
@overload
def get(self, key: _KT_contra, default: _T, /) -> _VT_co | _T: ...

# stable
class SupportsItems(Protocol[_KT_co, _VT_co]):
def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ...
Expand Down