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
14 changes: 14 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 All @@ -185,6 +197,8 @@ class SupportsItemAccess(Protocol[_KT_contra, _VT]):
def __setitem__(self, key: _KT_contra, value: _VT, /) -> None: ...
def __delitem__(self, key: _KT_contra, /) -> None: ...

# Path and file handling

StrPath: TypeAlias = str | PathLike[str] # stable
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable
GenericPath: TypeAlias = AnyStr | PathLike[AnyStr]
Expand Down