Added __class_getitem__ (#4695)

Resolves #4682

Co-authored-by: hauntsaninja <>
This commit is contained in:
Utsav
2020-10-23 02:35:04 +05:30
committed by GitHub
parent 5927e5ca30
commit 6f943d43ea
32 changed files with 205 additions and 6 deletions
+8
View File
@@ -1,5 +1,9 @@
import sys
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T")
class ContextVar(Generic[_T]):
@@ -9,6 +13,8 @@ class ContextVar(Generic[_T]):
def get(self, default: _T = ...) -> _T: ...
def set(self, value: _T) -> Token[_T]: ...
def reset(self, token: Token[_T]) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
class Token(Generic[_T]):
@property
@@ -16,6 +22,8 @@ class Token(Generic[_T]):
@property
def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express
MISSING: ClassVar[object]
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def copy_context() -> Context: ...