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: ...
|
||||
|
||||
Reference in New Issue
Block a user