From 5b17f78c3222defa2da44ac14381e3a8ee32f299 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Fri, 27 Dec 2024 19:56:08 -0800 Subject: [PATCH] typing: broaden type_check_only TypeVar bound (#13317) This is needed if we do https://discuss.python.org/t/protocol-classes-should-not-match-callable-proto/75475 --- stdlib/typing.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 0ba6a4ecb..cde626ed1 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -353,6 +353,8 @@ _F = TypeVar("_F", bound=Callable[..., Any]) _P = _ParamSpec("_P") _T = TypeVar("_T") +_FT = TypeVar("_FT", bound=Callable[..., Any] | type) + # These type variables are used by the container types. _S = TypeVar("_S") _KT = TypeVar("_KT") # Key type. @@ -367,7 +369,7 @@ def no_type_check(arg: _F) -> _F: ... def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # This itself is only available during type checking -def type_check_only(func_or_cls: _F) -> _F: ... +def type_check_only(func_or_cls: _FT) -> _FT: ... # Type aliases and type constructors