massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 3.7 / contextvars.pyi
1 from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, Union\r
2 \r
3 _T = TypeVar('_T')\r
4 \r
5 class ContextVar(Generic[_T]):\r
6     def __init__(self, name: str, *, default: _T = ...) -> None: ...\r
7     @property\r
8     def name(self) -> str: ...\r
9     def get(self, default: _T = ...) -> _T: ...\r
10     def set(self, value: _T) -> Token[_T]: ...\r
11     def reset(self, token: Token[_T]) -> None: ...\r
12 \r
13 class Token(Generic[_T]):\r
14     @property\r
15     def var(self) -> ContextVar[_T]: ...\r
16     @property\r
17     def old_value(self) -> Any: ...  # returns either _T or MISSING, but that's hard to express\r
18     MISSING: ClassVar[object]\r
19 \r
20 def copy_context() -> Context: ...\r
21 \r
22 # It doesn't make sense to make this generic, because for most Contexts each ContextVar will have\r
23 # a different value.\r
24 class Context(Mapping[ContextVar[Any], Any]):\r
25     def __init__(self) -> None: ...\r
26     def run(self, callable: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ...\r
27     def copy(self) -> Context: ...\r
28     def __getitem__(self, key: ContextVar[Any]) -> Any: ...\r
29     def __iter__(self) -> Iterator[ContextVar[Any]]: ...\r
30     def __len__(self) -> int: ...\r