Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from collections.abc import (
ValuesView,
)
from importlib.machinery import ModuleSpec
from typing import Any, ClassVar, Literal, ParamSpec, TypeVar, final, overload
from typing import Any, ClassVar, Generic, Literal, ParamSpec, TypeVar, final, overload
from typing_extensions import Self, TypeAliasType, TypeVarTuple, deprecated, disjoint_base

if sys.version_info >= (3, 14):
Expand Down Expand Up @@ -70,8 +70,13 @@ if sys.version_info >= (3, 15):

_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_P = ParamSpec("_P")
_P_default = ParamSpec("_P_default", default=...)
_R = TypeVar("_R")
_R_default = TypeVar("_R_default", default=Any)
_KT_co = TypeVar("_KT_co", covariant=True)
_VT_co = TypeVar("_VT_co", covariant=True)
_Fn = TypeVar("_Fn", bound=Callable[..., object])

# Make sure this class definition stays roughly in line with `builtins.function`
@final
Expand Down Expand Up @@ -461,7 +466,7 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
def __class_getitem__(cls, item: Any, /) -> Any: ...

@final
class MethodType:
class MethodType(Generic[_P_default, _R_default]):
@property
def __closure__(self) -> tuple[CellType, ...] | None: ... # inherited from the added function
@property
Expand All @@ -476,8 +481,8 @@ class MethodType:
def __name__(self) -> str: ... # inherited from the added function
@property
def __qualname__(self) -> str: ... # inherited from the added function
def __new__(cls, func: Callable[..., Any], instance: object, /) -> Self: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __new__(cls, func: Callable[_P_default, _R_default], instance: object, /) -> Self: ...
def __call__(self, *args: _P_default.args, **kwargs: _P_default.kwargs) -> _R_default: ...

if sys.version_info >= (3, 13):
def __get__(self, instance: object, owner: type | None = None, /) -> Self: ...
Expand Down Expand Up @@ -674,10 +679,6 @@ class DynamicClassAttribute(property):
def setter(self, fset: Callable[[Any, Any], object]) -> DynamicClassAttribute: ...
def deleter(self, fdel: Callable[[Any], object]) -> DynamicClassAttribute: ...

_Fn = TypeVar("_Fn", bound=Callable[..., object])
_R = TypeVar("_R")
_P = ParamSpec("_P")

# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
@overload
def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ...
Expand Down
Loading