diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index 3610bed14..ec2fe4956 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/bdb.pyi @@ -1,7 +1,9 @@ from types import CodeType, FrameType, TracebackType from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, TypeVar +from typing_extensions import ParamSpec _T = TypeVar("_T") +_P = ParamSpec("_P") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type _ExcInfo = tuple[type[BaseException], BaseException, FrameType] @@ -61,7 +63,7 @@ class Bdb: def run(self, cmd: str | CodeType, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... def runeval(self, expr: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... def runctx(self, cmd: str | CodeType, globals: dict[str, Any] | None, locals: Mapping[str, Any] | None) -> None: ... - def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... + def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... class Breakpoint: diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 2bb063c03..40731e2f3 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,6 +1,7 @@ from _typeshed import Self from types import CodeType from typing import Any, Callable, Text, TypeVar +from typing_extensions import ParamSpec def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -8,6 +9,7 @@ def runctx( ) -> None: ... _T = TypeVar("_T") +_P = ParamSpec("_P") _Label = tuple[str, int, str] class Profile: @@ -23,6 +25,6 @@ class Profile: def snapshot_stats(self) -> None: ... def run(self: Self, cmd: str) -> Self: ... def runctx(self: Self, cmd: str, globals: dict[str, Any], locals: dict[str, Any]) -> Self: ... - def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... + def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index 6cb18831f..8e68238fc 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -1,16 +1,18 @@ from types import TracebackType from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Protocol, TypeVar +from typing_extensions import ParamSpec _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _F = TypeVar("_F", bound=Callable[..., Any]) +_P = ParamSpec("_P") _ExitFunc = Callable[[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] class GeneratorContextManager(ContextManager[_T_co]): def __call__(self, func: _F) -> _F: ... -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, ContextManager[_T]]: ... def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... class _SupportsClose(Protocol): diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 78d0c163c..4600b5818 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -2,8 +2,10 @@ from bdb import Bdb from cmd import Cmd from types import FrameType, TracebackType from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, TypeVar +from typing_extensions import ParamSpec _T = TypeVar("_T") +_P = ParamSpec("_P") line_prefix: str # undocumented @@ -12,7 +14,7 @@ class Restart(Exception): ... def run(statement: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... def runeval(expression: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> Any: ... def runctx(statement: str, globals: dict[str, Any], locals: Mapping[str, Any]) -> None: ... -def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... +def runcall(func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... def set_trace() -> None: ... def post_mortem(t: TracebackType | None = ...) -> None: ... def pm() -> None: ... diff --git a/stdlib/@python2/profile.pyi b/stdlib/@python2/profile.pyi index 640cb930d..d9884038e 100644 --- a/stdlib/@python2/profile.pyi +++ b/stdlib/@python2/profile.pyi @@ -1,5 +1,6 @@ from _typeshed import Self from typing import Any, Callable, Text, TypeVar +from typing_extensions import ParamSpec def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -7,6 +8,7 @@ def runctx( ) -> None: ... _T = TypeVar("_T") +_P = ParamSpec("_P") _Label = tuple[str, int, str] class Profile: @@ -22,5 +24,5 @@ class Profile: def snapshot_stats(self) -> None: ... def run(self: Self, cmd: str) -> Self: ... def runctx(self: Self, cmd: str, globals: dict[str, Any], locals: dict[str, Any]) -> Self: ... - def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... + def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... def calibrate(self, m: int, verbose: int = ...) -> float: ... diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index 82777cd6a..aa35754cf 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -1,8 +1,10 @@ import types from _typeshed import StrPath from typing import Any, Callable, Mapping, Optional, Sequence, TypeVar +from typing_extensions import ParamSpec _T = TypeVar("_T") +_P = ParamSpec("_P") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] _fileModuleFunction = tuple[str, Optional[str], str] @@ -38,7 +40,7 @@ class Trace: def runctx( self, cmd: str | types.CodeType, globals: Mapping[str, Any] | None = ..., locals: Mapping[str, Any] | None = ... ) -> None: ... - def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... + def runfunc(self, func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ... def globaltrace_trackcallers(self, frame: types.FrameType, why: str, arg: Any) -> None: ... def globaltrace_countfuncs(self, frame: types.FrameType, why: str, arg: Any) -> None: ... diff --git a/stubs/futures/@python2/concurrent/futures/_base.pyi b/stubs/futures/@python2/concurrent/futures/_base.pyi index f4f827cbd..23edd20a9 100644 --- a/stubs/futures/@python2/concurrent/futures/_base.pyi +++ b/stubs/futures/@python2/concurrent/futures/_base.pyi @@ -4,6 +4,7 @@ from abc import abstractmethod from logging import Logger from types import TracebackType from typing import Any, Callable, Container, Generic, Iterable, Iterator, Optional, Protocol, TypeVar +from typing_extensions import ParamSpec FIRST_COMPLETED: str FIRST_EXCEPTION: str @@ -20,8 +21,8 @@ class CancelledError(Error): ... class TimeoutError(Error): ... _T = TypeVar("_T") - _T_co = TypeVar("_T_co", covariant=True) +_P = ParamSpec("_P") # Copied over Collection implementation as it does not exist in Python 2 and <3.6. # Also to solve pytype issues with _Collection. @@ -46,7 +47,7 @@ class Future(Generic[_T]): def set_exception_info(self, exception: Any, traceback: Optional[TracebackType]) -> None: ... class Executor: - def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... + def submit(self, fn: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ... def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...) -> Iterator[_T]: ... def shutdown(self, wait: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ...