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:
@@ -1,6 +1,9 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Generic, Optional, TypeVar, overload
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_C = TypeVar("_C", bound=Callable[..., Any])
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@@ -16,6 +19,8 @@ class ReferenceType(Generic[_T]):
|
||||
def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ...
|
||||
def __call__(self) -> Optional[_T]: ...
|
||||
def __hash__(self) -> int: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
ref = ReferenceType
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import sys
|
||||
from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
_SelfT = TypeVar("_SelfT", bound=WeakSet[Any])
|
||||
@@ -39,3 +43,5 @@ class WeakSet(MutableSet[_T], Generic[_T]):
|
||||
def union(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ...
|
||||
def __or__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ...
|
||||
def isdisjoint(self, other: Iterable[_T]) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@@ -21,6 +21,9 @@ from typing import (
|
||||
overload,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_DLLT = TypeVar("_DLLT", bound=CDLL)
|
||||
_CT = TypeVar("_CT", bound=_CData)
|
||||
@@ -58,6 +61,8 @@ class LibraryLoader(Generic[_DLLT]):
|
||||
def __getattr__(self, name: str) -> _DLLT: ...
|
||||
def __getitem__(self, name: str) -> _DLLT: ...
|
||||
def LoadLibrary(self, name: str) -> _DLLT: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
cdll: LibraryLoader[CDLL] = ...
|
||||
if sys.platform == "win32":
|
||||
@@ -302,3 +307,5 @@ class Array(Generic[_CT], _CData):
|
||||
# Can't inherit from Sized because the metaclass conflict between
|
||||
# Sized and _CData prevents using _CDataMeta.
|
||||
def __len__(self) -> int: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@@ -19,6 +19,9 @@ from typing import (
|
||||
overload,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
@@ -53,6 +56,8 @@ class SequenceMatcher(Generic[_T]):
|
||||
def ratio(self) -> float: ...
|
||||
def quick_ratio(self) -> float: ...
|
||||
def real_quick_ratio(self) -> float: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# mypy thinks the signatures of the overloads overlap, but the types still work fine
|
||||
@overload
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# Stubs for filecmp (Python 2/3)
|
||||
import sys
|
||||
from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Text, Tuple, Union
|
||||
from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Text, Tuple, Union
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from os import PathLike
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
DEFAULT_IGNORES: List[str]
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
@@ -41,7 +44,6 @@ class dircmp(Generic[AnyStr]):
|
||||
right: AnyStr
|
||||
hide: Sequence[AnyStr]
|
||||
ignore: Sequence[AnyStr]
|
||||
|
||||
# These properties are created at runtime by __getattr__
|
||||
subdirs: Dict[AnyStr, dircmp[AnyStr]]
|
||||
same_files: List[AnyStr]
|
||||
@@ -65,6 +67,8 @@ class dircmp(Generic[AnyStr]):
|
||||
def phase3(self) -> None: ...
|
||||
def phase4(self) -> None: ...
|
||||
def phase4_closure(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
def clear_cache() -> None: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import email.message
|
||||
import sys
|
||||
from _typeshed import AnyPath
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
@@ -24,6 +25,9 @@ from typing import (
|
||||
)
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_MessageType = TypeVar("_MessageType", bound=Message)
|
||||
_MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]]
|
||||
@@ -76,6 +80,8 @@ class Mailbox(Generic[_MessageType]):
|
||||
def lock(self) -> None: ...
|
||||
def unlock(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class Maildir(Mailbox[MaildirMessage]):
|
||||
|
||||
@@ -188,6 +194,8 @@ class _ProxyFile(Generic[AnyStr]):
|
||||
def flush(self) -> None: ...
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class _PartialFile(_ProxyFile[AnyStr]):
|
||||
def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -11,6 +11,9 @@ if sys.version_info < (3, 8):
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S")
|
||||
|
||||
@@ -58,5 +61,7 @@ class Future(Awaitable[_T], Iterable[_T]):
|
||||
def __await__(self) -> Generator[Any, None, _T]: ...
|
||||
@property
|
||||
def _loop(self) -> AbstractEventLoop: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
def wrap_future(future: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import sys
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from typing import Generic, Optional, TypeVar
|
||||
from typing import Any, Generic, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
class QueueEmpty(Exception): ...
|
||||
class QueueFull(Exception): ...
|
||||
@@ -25,6 +29,8 @@ class Queue(Generic[_T]):
|
||||
def get_nowait(self) -> _T: ...
|
||||
async def join(self) -> bool: ...
|
||||
def task_done(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||
|
||||
class PriorityQueue(Queue[_T]): ...
|
||||
class LifoQueue(Queue[_T]): ...
|
||||
|
||||
@@ -22,6 +22,9 @@ from typing_extensions import Literal
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_T1 = TypeVar("_T1")
|
||||
_T2 = TypeVar("_T2")
|
||||
@@ -189,6 +192,8 @@ class Task(Future[_T], Generic[_T]):
|
||||
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
|
||||
if sys.version_info < (3, 7):
|
||||
def _wakeup(self, fut: Future[Any]) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
|
||||
|
||||
@@ -858,6 +858,8 @@ class enumerate(Iterator[Tuple[int, _T]], Generic[_T]):
|
||||
def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ...
|
||||
def __iter__(self) -> Iterator[Tuple[int, _T]]: ...
|
||||
def __next__(self) -> Tuple[int, _T]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class range(Sequence[int]):
|
||||
start: int
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -18,6 +18,9 @@ from typing import (
|
||||
overload,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_AnyCallable = Callable[..., Any]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
@@ -68,6 +71,8 @@ class partial(Generic[_T]):
|
||||
keywords: Dict[str, Any]
|
||||
def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# With protocols, this could change into a generic protocol that defines __get__ and returns _T
|
||||
_Descriptor = Any
|
||||
@@ -83,6 +88,8 @@ class partialmethod(Generic[_T]):
|
||||
def __get__(self, obj: Any, cls: Type[Any]) -> Callable[..., _T]: ...
|
||||
@property
|
||||
def __isabstractmethod__(self) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class _SingleDispatchCallable(Generic[_T]):
|
||||
registry: Mapping[Any, Callable[..., _T]]
|
||||
@@ -115,6 +122,8 @@ if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def __get__(self, instance: _S, owner: Optional[Type[Any]] = ...) -> _T: ...
|
||||
def __set_name__(self, owner: Type[Any], name: str) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ...
|
||||
|
||||
@@ -30,6 +30,9 @@ if sys.version_info >= (3, 8):
|
||||
_SharedMemory = SharedMemory
|
||||
_ShareableList = ShareableList
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
@@ -89,6 +92,8 @@ class ValueProxy(BaseProxy, Generic[_T]):
|
||||
def get(self) -> _T: ...
|
||||
def set(self, value: _T) -> None: ...
|
||||
value: _T
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# Returned by BaseManager.get_server()
|
||||
class Server:
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import sys
|
||||
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_PT = TypeVar("_PT", bound=Pool)
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
@@ -9,6 +13,8 @@ class ApplyResult(Generic[_T]):
|
||||
def wait(self, timeout: Optional[float] = ...) -> None: ...
|
||||
def ready(self) -> bool: ...
|
||||
def successful(self) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# alias created during issue #17805
|
||||
AsyncResult = ApplyResult
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import queue
|
||||
import sys
|
||||
from typing import Any, Generic, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Queue(queue.Queue[_T]):
|
||||
@@ -27,3 +31,5 @@ class SimpleQueue(Generic[_T]):
|
||||
def empty(self) -> bool: ...
|
||||
def get(self) -> _T: ...
|
||||
def put(self, item: _T) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import sys
|
||||
from typing import Generic, Iterable, Optional, Tuple, TypeVar
|
||||
from typing import Any, Generic, Iterable, Optional, Tuple, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_SLT = TypeVar("_SLT", int, float, bool, str, bytes, None)
|
||||
@@ -26,3 +29,5 @@ if sys.version_info >= (3, 8):
|
||||
def format(self) -> str: ...
|
||||
def count(self, value: _SLT) -> int: ...
|
||||
def index(self, value: _SLT) -> int: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@@ -38,6 +38,9 @@ from typing_extensions import Literal
|
||||
|
||||
from . import path as path
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
# We need to use something from path, or flake8 and pytype get unhappy
|
||||
_supports_unicode_filenames = path.supports_unicode_filenames
|
||||
|
||||
@@ -288,6 +291,8 @@ if sys.version_info >= (3, 6):
|
||||
def is_symlink(self) -> bool: ...
|
||||
def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ...
|
||||
def __fspath__(self) -> AnyStr: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
else:
|
||||
class DirEntry(Generic[AnyStr]):
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -6,6 +6,9 @@ import sys
|
||||
from threading import Condition, Lock
|
||||
from typing import Any, Generic, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Empty(Exception): ...
|
||||
@@ -34,6 +37,8 @@ class Queue(Generic[_T]):
|
||||
def qsize(self) -> int: ...
|
||||
def _qsize(self) -> int: ...
|
||||
def task_done(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class PriorityQueue(Queue[_T]): ...
|
||||
class LifoQueue(Queue[_T]): ...
|
||||
@@ -47,3 +52,5 @@ if sys.version_info >= (3, 7):
|
||||
def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def put_nowait(self, item: _T) -> None: ...
|
||||
def qsize(self) -> int: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@@ -4,6 +4,9 @@ from types import TracebackType
|
||||
from typing import IO, Any, AnyStr, Callable, Generic, Mapping, Optional, Sequence, Tuple, Type, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
# We prefer to annotate inputs to methods (eg subprocess.check_call) with these
|
||||
# union types.
|
||||
# For outputs we use laborious literal based overloads to try to determine
|
||||
@@ -38,6 +41,8 @@ class CompletedProcess(Generic[_T]):
|
||||
stderr: _T
|
||||
def __init__(self, args: _CMD, returncode: int, stdout: Optional[_T] = ..., stderr: Optional[_T] = ...) -> None: ...
|
||||
def check_returncode(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
# Nearly the same args as for 3.6, except for capture_output and text
|
||||
@@ -1211,6 +1216,8 @@ class Popen(Generic[AnyStr]):
|
||||
def __exit__(
|
||||
self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# The result really is always a str.
|
||||
def getstatusoutput(cmd: _TXT) -> Tuple[int, str]: ...
|
||||
|
||||
@@ -4,6 +4,9 @@ from types import TracebackType
|
||||
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
# global variables
|
||||
TMP_MAX: int
|
||||
tempdir: Optional[str]
|
||||
@@ -287,6 +290,8 @@ class TemporaryDirectory(Generic[AnyStr]):
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
def mkstemp(
|
||||
suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., text: bool = ...
|
||||
|
||||
@@ -3,6 +3,9 @@ import sys
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from types import CodeType, FrameType, TracebackType
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
# Definitions of special type checking related constructs. Their definitions
|
||||
# are not used, so their value does not matter.
|
||||
|
||||
@@ -167,6 +170,8 @@ class Hashable(Protocol, metaclass=ABCMeta):
|
||||
class Iterable(Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
def __iter__(self) -> Iterator[_T_co]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@runtime_checkable
|
||||
class Iterator(Iterable[_T_co], Protocol[_T_co]):
|
||||
@@ -201,6 +206,8 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
class Awaitable(Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
def __await__(self) -> Generator[Any, None, _T_co]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
__name__: str
|
||||
@@ -236,6 +243,8 @@ class AwaitableGenerator(
|
||||
class AsyncIterable(Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
def __aiter__(self) -> AsyncIterator[_T_co]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
@runtime_checkable
|
||||
class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]):
|
||||
@@ -274,6 +283,8 @@ if sys.version_info >= (3, 6):
|
||||
class Container(Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
def __contains__(self, __x: object) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
@runtime_checkable
|
||||
@@ -364,6 +375,8 @@ class MutableSet(AbstractSet[_T], Generic[_T]):
|
||||
class MappingView(Sized):
|
||||
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
|
||||
def __len__(self) -> int: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
|
||||
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
|
||||
@@ -568,6 +581,8 @@ class Match(Generic[AnyStr]):
|
||||
def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented
|
||||
if sys.version_info >= (3, 6):
|
||||
def __getitem__(self, g: Union[int, str]) -> AnyStr: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class Pattern(Generic[AnyStr]):
|
||||
flags: int
|
||||
@@ -589,6 +604,8 @@ class Pattern(Generic[AnyStr]):
|
||||
def subn(self, repl: AnyStr, string: AnyStr, count: int = ...) -> Tuple[AnyStr, int]: ...
|
||||
@overload
|
||||
def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> Tuple[AnyStr, int]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
# Functions
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ from typing import (
|
||||
)
|
||||
from warnings import WarningMessage
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_E = TypeVar("_E", bound=BaseException)
|
||||
_FT = TypeVar("_FT", bound=Callable[..., Any])
|
||||
|
||||
@@ -258,6 +261,8 @@ class _AssertRaisesContext(Generic[_E]):
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class _AssertWarnsContext:
|
||||
warning: WarningMessage
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import sys
|
||||
from typing import Any, AnyStr, Callable, Dict, Generic, List, Mapping, NamedTuple, Optional, Sequence, Tuple, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_Str = Union[bytes, str]
|
||||
|
||||
uses_relative: List[str]
|
||||
@@ -27,6 +30,8 @@ class _NetlocResultMixinBase(Generic[AnyStr]):
|
||||
password: Optional[AnyStr]
|
||||
hostname: Optional[AnyStr]
|
||||
port: Optional[int]
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ...
|
||||
class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ...
|
||||
|
||||
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