mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Added __class_getitem__ (#4695)
Resolves #4682 Co-authored-by: hauntsaninja <>
This commit is contained in:
5
third_party/2/concurrent/futures/_base.pyi
vendored
5
third_party/2/concurrent/futures/_base.pyi
vendored
@@ -5,6 +5,9 @@ from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Container, Generic, Iterable, Iterator, List, Optional, Protocol, Set, Tuple, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
FIRST_COMPLETED: str
|
||||
FIRST_EXCEPTION: str
|
||||
ALL_COMPLETED: str
|
||||
@@ -54,6 +57,8 @@ class Future(Generic[_T]):
|
||||
def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ...
|
||||
def set_exception(self, exception: Any) -> None: ...
|
||||
def set_exception_info(self, exception: Any, traceback: Optional[TracebackType]) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class Executor:
|
||||
if sys.version_info >= (3, 9):
|
||||
|
||||
5
third_party/2/concurrent/futures/thread.pyi
vendored
5
third_party/2/concurrent/futures/thread.pyi
vendored
@@ -7,6 +7,9 @@ if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor
|
||||
class BrokenThreadPool(BrokenExecutor): ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_S = TypeVar("_S")
|
||||
|
||||
class ThreadPoolExecutor(Executor):
|
||||
@@ -30,3 +33,5 @@ class _WorkItem(Generic[_S]):
|
||||
kwargs: Mapping[str, Any]
|
||||
def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
5
third_party/2/pathlib2.pyi
vendored
5
third_party/2/pathlib2.pyi
vendored
@@ -6,6 +6,9 @@ from types import TracebackType
|
||||
from typing import IO, Any, BinaryIO, Generator, List, Optional, Sequence, Text, TextIO, Tuple, Type, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_P = TypeVar("_P", bound=PurePath)
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
@@ -52,6 +55,8 @@ class PurePath(_PurePathBase):
|
||||
def parents(self: _P) -> Sequence[_P]: ...
|
||||
@property
|
||||
def parent(self: _P) -> _P: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||
|
||||
class PurePosixPath(PurePath): ...
|
||||
class PureWindowsPath(PurePath): ...
|
||||
|
||||
8
third_party/3/contextvars.pyi
vendored
8
third_party/3/contextvars.pyi
vendored
@@ -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: ...
|
||||
|
||||
|
||||
11
third_party/3/dataclasses.pyi
vendored
11
third_party/3/dataclasses.pyi
vendored
@@ -1,5 +1,9 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class _MISSING_TYPE: ...
|
||||
@@ -32,6 +36,8 @@ class Field(Generic[_T]):
|
||||
init: bool
|
||||
compare: bool
|
||||
metadata: Mapping[str, Any]
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# NOTE: Actual return type is 'Field[_T]', but we want to help type checkers
|
||||
# to understand the magic that happens at runtime.
|
||||
@@ -68,7 +74,10 @@ def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ...
|
||||
def is_dataclass(obj: Any) -> bool: ...
|
||||
|
||||
class FrozenInstanceError(AttributeError): ...
|
||||
class InitVar(Generic[_T]): ...
|
||||
|
||||
class InitVar(Generic[_T]):
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||
|
||||
def make_dataclass(
|
||||
cls_name: str,
|
||||
|
||||
Reference in New Issue
Block a user