Skip to content

Commit 2ae6722

Browse files
committed
fix typing.Callable
1 parent bf484ab commit 2ae6722

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

stdlib/_collections_abc.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from typing import ( # noqa: Y022,Y038,UP035
77
AsyncIterable as AsyncIterable,
88
AsyncIterator as AsyncIterator,
99
Awaitable as Awaitable,
10-
Callable as Callable,
1110
ClassVar,
1211
Collection as Collection,
1312
Container as Container,
@@ -31,7 +30,7 @@ from typing import ( # noqa: Y022,Y038,UP035
3130
TypeVar,
3231
ValuesView as ValuesView,
3332
final,
34-
runtime_checkable,
33+
runtime_checkable, ParamSpec,
3534
)
3635

3736
__all__ = [
@@ -68,9 +67,18 @@ if sys.version_info < (3, 14):
6867
if sys.version_info >= (3, 12):
6968
__all__ += ["Buffer"]
7069

70+
_T_co = TypeVar("_T_co", covariant=True)
7171
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
7272
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
7373

74+
_P = ParamSpec("_P")
75+
76+
77+
class Callable(Protocol[_P, _T_co]):
78+
@abstractmethod
79+
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T_co: ...
80+
81+
7482
@final
7583
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
7684
def __eq__(self, value: object, /) -> bool: ...

stdlib/typing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class _SpecialForm(_Final):
239239

240240
Union: _SpecialForm
241241
Protocol: _SpecialForm
242-
Callable: _SpecialForm
242+
Callable = _Alias()
243243
Type: _SpecialForm
244244
NoReturn: _SpecialForm
245245
ClassVar: _SpecialForm

0 commit comments

Comments
 (0)