Use TypeIs for various stdlib functions (#11823)

This commit is contained in:
Jelle Zijlstra
2024-04-26 16:43:19 -07:00
committed by GitHub
parent 48a68f521e
commit 1dff589dd4
2 changed files with 23 additions and 20 deletions

View File

@@ -66,6 +66,7 @@ from typing_extensions import ( # noqa: Y023
Self,
TypeAlias,
TypeGuard,
TypeIs,
TypeVarTuple,
deprecated,
)
@@ -1241,7 +1242,7 @@ def any(iterable: Iterable[object], /) -> bool: ...
def ascii(obj: object, /) -> str: ...
def bin(number: int | SupportsIndex, /) -> str: ...
def breakpoint(*args: Any, **kws: Any) -> None: ...
def callable(obj: object, /) -> TypeGuard[Callable[..., object]]: ...
def callable(obj: object, /) -> TypeIs[Callable[..., object]]: ...
def chr(i: int, /) -> str: ...
# We define this here instead of using os.PathLike to avoid import cycle issues.
@@ -1351,6 +1352,8 @@ class filter(Iterator[_T]):
@overload
def __new__(cls, function: Callable[[_S], TypeGuard[_T]], iterable: Iterable[_S], /) -> Self: ...
@overload
def __new__(cls, function: Callable[[_S], TypeIs[_T]], iterable: Iterable[_S], /) -> Self: ...
@overload
def __new__(cls, function: Callable[[_T], Any], iterable: Iterable[_T], /) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...