diff --git a/stdlib/@tests/test_cases/builtins/check_callable.py b/stdlib/@tests/test_cases/builtins/check_callable.py new file mode 100644 index 000000000000..ba039a24d8bf --- /dev/null +++ b/stdlib/@tests/test_cases/builtins/check_callable.py @@ -0,0 +1,10 @@ +# mypy: disable-error-code="no-any-return" + +from typing import Any + + +def check_gradual_guarantee(arg: Any) -> int: + # if Any materialized to `Callable[[], int] | None`, this function type checks + if callable(arg): + return arg() + return -1 diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 096d440ac38c..372cfe7de5d3 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1568,7 +1568,7 @@ else: def bin(number: SupportsIndex, /) -> str: ... def breakpoint(*args: Any, **kws: Any) -> None: ... -def callable(obj: object, /) -> TypeIs[Callable[..., object]]: ... +def callable(obj: object, /) -> TypeIs[Callable[..., Any]]: ... def chr(i: SupportsIndex, /) -> str: ... def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ...