Skip to content

Commit 11077b4

Browse files
committed
fix collections.abc.Callable and typing.Callable
1 parent ad3d849 commit 11077b4

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
@@ -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,
@@ -32,7 +31,7 @@ from typing import ( # noqa: Y022,Y038,UP035,Y057
3231
TypeVar,
3332
ValuesView as ValuesView,
3433
final,
35-
runtime_checkable,
34+
runtime_checkable, ParamSpec,
3635
)
3736

3837
__all__ = [
@@ -65,9 +64,18 @@ __all__ = [
6564
if sys.version_info >= (3, 12):
6665
__all__ += ["Buffer"]
6766

67+
_T_co = TypeVar("_T_co", covariant=True)
6868
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
6969
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
7070

71+
_P = ParamSpec("_P")
72+
73+
74+
class Callable(Protocol[_P, _T_co]):
75+
@abstractmethod
76+
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T_co: ...
77+
78+
7179
@final
7280
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
7381
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,7 @@ class _SpecialForm(_Final):
237237

238238
Union: _SpecialForm
239239
Protocol: _SpecialForm
240-
Callable: _SpecialForm
240+
Callable = _Alias()
241241
Type: _SpecialForm
242242
NoReturn: _SpecialForm
243243
ClassVar: _SpecialForm

0 commit comments

Comments
 (0)