Skip to content

Commit 17f5d58

Browse files
committed
fix collections.abc.Callable and typing.Callable
1 parent ad3d849 commit 17f5d58

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

stdlib/_collections_abc.pyi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from typing import ( # noqa: Y022,Y038,UP035,Y057
88
AsyncIterator as AsyncIterator,
99
Awaitable as Awaitable,
1010
ByteString as ByteString,
11-
Callable as Callable,
1211
ClassVar,
1312
Collection as Collection,
1413
Container as Container,
@@ -25,6 +24,7 @@ from typing import ( # noqa: Y022,Y038,UP035,Y057
2524
MutableMapping as MutableMapping,
2625
MutableSequence as MutableSequence,
2726
MutableSet as MutableSet,
27+
ParamSpec,
2828
Protocol,
2929
Reversible as Reversible,
3030
Sequence as Sequence,
@@ -65,9 +65,16 @@ __all__ = [
6565
if sys.version_info >= (3, 12):
6666
__all__ += ["Buffer"]
6767

68+
_T_co = TypeVar("_T_co", covariant=True)
6869
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
6970
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
7071

72+
_P = ParamSpec("_P")
73+
74+
class Callable(Protocol[_P, _T_co]):
75+
@abstractmethod
76+
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T_co: ...
77+
7178
@final
7279
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
7380
def __eq__(self, value: object, /) -> bool: ...

stdlib/typing.pyi

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

238238
Union: _SpecialForm
239239
Protocol: _SpecialForm
240-
Callable: _SpecialForm
241240
Type: _SpecialForm
242241
NoReturn: _SpecialForm
243242
ClassVar: _SpecialForm
@@ -424,6 +423,7 @@ class _Alias:
424423
# Class for defining generic aliases for library types.
425424
def __getitem__(self, typeargs: Any) -> Any: ...
426425

426+
Callable = _Alias()
427427
List = _Alias()
428428
Dict = _Alias()
429429
DefaultDict = _Alias()

0 commit comments

Comments
 (0)