mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Use ParamSpec for contextvars.Context.run (#6940)
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import sys
|
||||
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, overload
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_D = TypeVar("_D")
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
class ContextVar(Generic[_T]):
|
||||
def __init__(self, name: str, *, default: _T = ...) -> None: ...
|
||||
@@ -39,7 +41,7 @@ class Context(Mapping[ContextVar[Any], Any]):
|
||||
def get(self, __key: ContextVar[Any]) -> Any | None: ...
|
||||
@overload
|
||||
def get(self, __key: ContextVar[Any], __default: Any | None) -> Any: ...
|
||||
def run(self, callable: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ...
|
||||
def run(self, callable: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
|
||||
def copy(self) -> Context: ...
|
||||
def __getitem__(self, key: ContextVar[Any]) -> Any: ...
|
||||
def __iter__(self) -> Iterator[ContextVar[Any]]: ...
|
||||
|
||||
Reference in New Issue
Block a user