mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-09 13:02:22 +08:00
stdlib: Add many missing dunder overrides (#7231)
This commit is contained in:
@@ -324,6 +324,7 @@ class Namespace(_AttributeHolder):
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __setattr__(self, __name: str, __value: Any) -> None: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class FileType:
|
||||
# undocumented
|
||||
|
||||
@@ -59,6 +59,7 @@ class TimerHandle(Handle):
|
||||
def __le__(self, other: TimerHandle) -> bool: ...
|
||||
def __gt__(self, other: TimerHandle) -> bool: ...
|
||||
def __ge__(self, other: TimerHandle) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class AbstractServer:
|
||||
@abstractmethod
|
||||
|
||||
@@ -82,6 +82,7 @@ class UserList(MutableSequence[_T]):
|
||||
def __le__(self, other: list[_T] | UserList[_T]) -> bool: ...
|
||||
def __gt__(self, other: list[_T] | UserList[_T]) -> bool: ...
|
||||
def __ge__(self, other: list[_T] | UserList[_T]) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __contains__(self, item: object) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
@overload
|
||||
@@ -125,6 +126,7 @@ class UserString(Sequence[UserString]):
|
||||
def __le__(self, string: str | UserString) -> bool: ...
|
||||
def __gt__(self, string: str | UserString) -> bool: ...
|
||||
def __ge__(self, string: str | UserString) -> bool: ...
|
||||
def __eq__(self, string: object) -> bool: ...
|
||||
def __contains__(self, char: object) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __getitem__(self: Self, i: SupportsIndex | slice) -> Self: ...
|
||||
@@ -267,6 +269,9 @@ class Counter(dict[_T, int], Generic[_T]):
|
||||
def update(self, __m: Iterable[_T] | Iterable[tuple[_T, int]], **kwargs: int) -> None: ...
|
||||
@overload
|
||||
def update(self, __m: None = ..., **kwargs: int) -> None: ...
|
||||
def __delitem__(self, elem: object) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
def __add__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
def __and__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
@@ -362,6 +367,7 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __getitem__(self, k: _KT) -> _VT: ...
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __contains__(self, key: object) -> bool: ...
|
||||
def __missing__(self, key: _KT) -> _VT: ... # undocumented
|
||||
def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ...
|
||||
@overload
|
||||
|
||||
@@ -80,6 +80,7 @@ class RawConfigParser(_parser):
|
||||
def __setitem__(self, section: str, options: _section) -> None: ...
|
||||
def __delitem__(self, section: str) -> None: ...
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
def __contains__(self, key: object) -> bool: ...
|
||||
def defaults(self) -> _section: ...
|
||||
def sections(self) -> list[str]: ...
|
||||
def add_section(self, section: str) -> None: ...
|
||||
|
||||
@@ -46,6 +46,9 @@ class _GeneratorContextManager(AbstractContextManager[_T_co], ContextDecorator,
|
||||
func: Callable[..., Generator[_T_co, Any, Any]]
|
||||
args: tuple[Any, ...]
|
||||
kwds: dict[str, Any]
|
||||
def __exit__(
|
||||
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
||||
) -> bool | None: ...
|
||||
|
||||
def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ...
|
||||
|
||||
@@ -63,6 +66,9 @@ if sys.version_info >= (3, 10):
|
||||
func: Callable[..., AsyncGenerator[_T_co, Any]]
|
||||
args: tuple[Any, ...]
|
||||
kwds: dict[str, Any]
|
||||
async def __aexit__(
|
||||
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
||||
) -> bool | None: ...
|
||||
|
||||
elif sys.version_info >= (3, 7):
|
||||
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]):
|
||||
|
||||
@@ -47,6 +47,7 @@ class Example:
|
||||
options: dict[int, bool] | None = ...,
|
||||
) -> None: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class DocTest:
|
||||
examples: list[Example]
|
||||
@@ -66,6 +67,7 @@ class DocTest:
|
||||
) -> None: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __lt__(self, other: DocTest) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class DocTestParser:
|
||||
def parse(self, string: str, name: str = ...) -> list[str | Example]: ...
|
||||
@@ -172,6 +174,7 @@ class DocTestCase(unittest.TestCase):
|
||||
def debug(self) -> None: ...
|
||||
def id(self) -> str: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def shortDescription(self) -> str: ...
|
||||
|
||||
class SkipDocTestCase(DocTestCase):
|
||||
|
||||
@@ -161,6 +161,7 @@ class Address:
|
||||
def __init__(
|
||||
self, display_name: str = ..., username: str | None = ..., domain: str | None = ..., addr_spec: str | None = ...
|
||||
) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class Group:
|
||||
@property
|
||||
@@ -168,3 +169,4 @@ class Group:
|
||||
@property
|
||||
def addresses(self) -> tuple[Address, ...]: ...
|
||||
def __init__(self, display_name: str | None = ..., addresses: Iterable[Address] | None = ...) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
@@ -25,6 +25,7 @@ _EnumNames = Union[str, Iterable[str], Iterable[Iterable[Union[str, Any]]], Mapp
|
||||
|
||||
class _EnumDict(dict[str, Any]):
|
||||
def __init__(self) -> None: ...
|
||||
def __setitem__(self, key: str, value: Any) -> None: ...
|
||||
|
||||
# Note: EnumMeta actually subclasses type directly, not ABCMeta.
|
||||
# This is a temporary workaround to allow multiple creation of enums with builtins
|
||||
@@ -56,6 +57,8 @@ class EnumMeta(ABCMeta):
|
||||
def __members__(self: type[_T]) -> types.MappingProxyType[str, _T]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __bool__(self) -> Literal[True]: ...
|
||||
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||
def __delattr__(self, name: str) -> None: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
# Simple value lookup
|
||||
@overload # type: ignore[override]
|
||||
|
||||
@@ -38,6 +38,8 @@ class Morsel(dict[str, Any], Generic[_T]):
|
||||
def output(self, attrs: list[str] | None = ..., header: str = ...) -> str: ...
|
||||
def js_output(self, attrs: list[str] | None = ...) -> str: ...
|
||||
def OutputString(self, attrs: list[str] | None = ...) -> str: ...
|
||||
def __eq__(self, morsel: object) -> bool: ...
|
||||
def __setitem__(self, K: str, V: Any) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class ModuleSpec:
|
||||
cached: str | None
|
||||
parent: str | None
|
||||
has_location: bool
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
# MetaPathFinder
|
||||
@@ -144,3 +145,4 @@ class ExtensionFileLoader(importlib.abc.ExecutionLoader):
|
||||
def exec_module(self, module: types.ModuleType) -> None: ...
|
||||
def is_package(self, fullname: str) -> bool: ...
|
||||
def get_code(self, fullname: str) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
@@ -189,6 +189,8 @@ class Signature:
|
||||
@classmethod
|
||||
def from_callable(cls: type[Self], obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Self: ...
|
||||
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
def get_annotations(
|
||||
obj: Callable[..., Any] | type[Any] | ModuleType,
|
||||
@@ -235,6 +237,7 @@ class Parameter:
|
||||
default: Any = ...,
|
||||
annotation: Any = ...,
|
||||
) -> Self: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class BoundArguments:
|
||||
arguments: OrderedDict[str, Any]
|
||||
@@ -243,6 +246,7 @@ class BoundArguments:
|
||||
signature: Signature
|
||||
def __init__(self, signature: Signature, arguments: OrderedDict[str, Any]) -> None: ...
|
||||
def apply_defaults(self) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
#
|
||||
# Classes and functions
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import queue
|
||||
import sys
|
||||
import threading
|
||||
from contextlib import AbstractContextManager
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, TypeVar
|
||||
|
||||
from .connection import Connection
|
||||
@@ -69,7 +70,7 @@ class Server:
|
||||
def serve_forever(self) -> None: ...
|
||||
def accept_connection(self, c: Connection, name: str) -> None: ...
|
||||
|
||||
class BaseManager(AbstractContextManager[BaseManager]):
|
||||
class BaseManager:
|
||||
def __init__(
|
||||
self, address: Any | None = ..., authkey: bytes | None = ..., serializer: str = ..., ctx: BaseContext | None = ...
|
||||
) -> None: ...
|
||||
@@ -90,12 +91,14 @@ class BaseManager(AbstractContextManager[BaseManager]):
|
||||
method_to_typeid: Mapping[str, str] | None = ...,
|
||||
create_method: bool = ...,
|
||||
) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, exc_type: type[BaseException], exc_val: BaseException, exc_tb: TracebackType) -> None: ...
|
||||
|
||||
# Conflicts with method names
|
||||
_dict = dict
|
||||
_list = list
|
||||
|
||||
class SyncManager(BaseManager, AbstractContextManager[SyncManager]):
|
||||
class SyncManager(BaseManager):
|
||||
def BoundedSemaphore(self, value: Any = ...) -> threading.BoundedSemaphore: ...
|
||||
def Condition(self, lock: Any = ...) -> threading.Condition: ...
|
||||
def Event(self) -> threading.Event: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from contextlib import AbstractContextManager
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, TypeVar
|
||||
from typing_extensions import Literal
|
||||
|
||||
@@ -67,7 +67,7 @@ class IMapIterator(Iterator[_T]):
|
||||
|
||||
class IMapUnorderedIterator(IMapIterator[_T]): ...
|
||||
|
||||
class Pool(AbstractContextManager[Pool]):
|
||||
class Pool:
|
||||
def __init__(
|
||||
self,
|
||||
processes: int | None = ...,
|
||||
@@ -111,8 +111,9 @@ class Pool(AbstractContextManager[Pool]):
|
||||
def terminate(self) -> None: ...
|
||||
def join(self) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, exc_type: type[BaseException], exc_val: BaseException, exc_tb: TracebackType) -> None: ...
|
||||
|
||||
class ThreadPool(Pool, AbstractContextManager[ThreadPool]):
|
||||
class ThreadPool(Pool):
|
||||
def __init__(
|
||||
self, processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...
|
||||
) -> None: ...
|
||||
|
||||
@@ -161,6 +161,7 @@ class Values:
|
||||
def read_module(self, modname: str, mode: str = ...) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __setattr__(self, __name: str, __value: Any) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class OptionParser(OptionContainer):
|
||||
allow_interspersed_args: bool
|
||||
|
||||
@@ -28,6 +28,7 @@ class PurePath(PathLike[str]):
|
||||
stem: str
|
||||
def __new__(cls: type[Self], *args: StrPath) -> Self: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __lt__(self, other: PurePath) -> bool: ...
|
||||
def __le__(self, other: PurePath) -> bool: ...
|
||||
def __gt__(self, other: PurePath) -> bool: ...
|
||||
|
||||
@@ -71,6 +71,7 @@ if sys.version_info >= (3, 8):
|
||||
def __index__(self) -> int: ...
|
||||
def __reduce__(self: Self) -> tuple[type[Self], tuple[int]]: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class InvalidFileException(ValueError):
|
||||
def __init__(self, message: str = ...) -> None: ...
|
||||
|
||||
@@ -20,6 +20,7 @@ class Shelf(MutableMapping[str, _VT]):
|
||||
def __getitem__(self, key: str) -> _VT: ...
|
||||
def __setitem__(self, key: str, value: _VT) -> None: ...
|
||||
def __delitem__(self, key: str) -> None: ...
|
||||
def __contains__(self, key: str) -> bool: ... # type: ignore[override]
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
||||
|
||||
@@ -67,6 +67,7 @@ if sys.version_info >= (3, 8):
|
||||
if sys.version_info >= (3, 9):
|
||||
def zscore(self, x: float) -> float: ...
|
||||
|
||||
def __eq__(self, x2: object) -> bool: ...
|
||||
def __add__(self, x2: float | NormalDist) -> NormalDist: ...
|
||||
def __sub__(self, x2: float | NormalDist) -> NormalDist: ...
|
||||
def __mul__(self, x2: float) -> NormalDist: ...
|
||||
|
||||
@@ -142,6 +142,7 @@ class Variable:
|
||||
def trace_vdelete(self, mode, cbname) -> None: ... # deprecated
|
||||
def trace_vinfo(self): ... # deprecated
|
||||
trace = trace_variable # deprecated
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class StringVar(Variable):
|
||||
def __init__(self, master: Misc | None = ..., value: str | None = ..., name: str | None = ...) -> None: ...
|
||||
|
||||
@@ -101,6 +101,7 @@ class Font:
|
||||
@overload
|
||||
def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ...
|
||||
def measure(self, text: str, displayof: tkinter.Misc | None = ...) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> tuple[str, ...]: ...
|
||||
def names(root: tkinter.Misc | None = ...) -> tuple[str, ...]: ...
|
||||
|
||||
@@ -124,6 +124,7 @@ class TracebackException:
|
||||
cls: type[Self], exc: BaseException, *, limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ...
|
||||
) -> Self: ...
|
||||
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ...
|
||||
def format_exception_only(self) -> Generator[str, None, None]: ...
|
||||
|
||||
@@ -173,6 +174,7 @@ class FrameSummary(Iterable[Any]):
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> Any: ...
|
||||
def __iter__(self) -> Iterator[Any]: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __len__(self) -> Literal[4]: ...
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class Statistic:
|
||||
size: int
|
||||
traceback: Traceback
|
||||
def __init__(self, traceback: Traceback, size: int, count: int) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class StatisticDiff:
|
||||
count: int
|
||||
@@ -34,6 +35,7 @@ class StatisticDiff:
|
||||
size_diff: int
|
||||
traceback: Traceback
|
||||
def __init__(self, traceback: Traceback, size: int, size_diff: int, count: int, count_diff: int) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
_FrameTupleT = tuple[str, int]
|
||||
|
||||
@@ -61,6 +63,7 @@ class Trace:
|
||||
size: int
|
||||
traceback: Traceback
|
||||
def __init__(self, trace: _TraceTupleT) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class Traceback(Sequence[Frame]):
|
||||
if sys.version_info >= (3, 9):
|
||||
@@ -78,6 +81,7 @@ class Traceback(Sequence[Frame]):
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> Sequence[Frame]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __lt__(self, other: Traceback) -> bool: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
def __gt__(self, other: Traceback) -> bool: ...
|
||||
|
||||
@@ -82,6 +82,7 @@ class TestCase:
|
||||
# undocumented
|
||||
_testMethodDoc: str
|
||||
def __init__(self, methodName: str = ...) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def setUp(self) -> None: ...
|
||||
def tearDown(self) -> None: ...
|
||||
@classmethod
|
||||
|
||||
@@ -128,6 +128,8 @@ class NonCallableMock(Base, Any):
|
||||
**kwargs: Any,
|
||||
) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __delattr__(self, name: str) -> None: ...
|
||||
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def _calls_repr(self, prefix: str = ...) -> str: ...
|
||||
def assert_called_with(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
@@ -15,6 +15,7 @@ class BaseTestSuite(Iterable[_TestType]):
|
||||
def debug(self) -> None: ...
|
||||
def countTestCases(self) -> int: ...
|
||||
def __iter__(self) -> Iterator[_TestType]: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class TestSuite(BaseTestSuite):
|
||||
def run(self, result: unittest.result.TestResult, debug: bool = ...) -> unittest.result.TestResult: ...
|
||||
|
||||
@@ -27,6 +27,8 @@ ProxyTypes: tuple[type[Any], ...]
|
||||
class WeakMethod(ref[_CallableT], Generic[_CallableT]):
|
||||
def __new__(cls: type[Self], meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> Self: ...
|
||||
def __call__(self) -> _CallableT | None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
|
||||
class WeakValueDictionary(MutableMapping[_KT, _VT]):
|
||||
@overload
|
||||
|
||||
@@ -115,6 +115,7 @@ class QName:
|
||||
def __le__(self, other: QName | str) -> bool: ...
|
||||
def __gt__(self, other: QName | str) -> bool: ...
|
||||
def __ge__(self, other: QName | str) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class ElementTree:
|
||||
def __init__(self, element: Element | None = ..., file: _File | None = ...) -> None: ...
|
||||
|
||||
@@ -83,6 +83,7 @@ class Binary:
|
||||
def __init__(self, data: bytes | None = ...) -> None: ...
|
||||
def decode(self, data: bytes) -> None: ...
|
||||
def encode(self, out: SupportsWrite[str]) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
def _binary(data: bytes) -> Binary: ... # undocumented
|
||||
|
||||
|
||||
Reference in New Issue
Block a user