mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Use typing_extensions.Self in the stdlib (#9694)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
from _typeshed import ReadableBuffer, Self
|
||||
from _typeshed import ReadableBuffer
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
from typing_extensions import SupportsIndex, TypeAlias
|
||||
from typing_extensions import Self, SupportsIndex, TypeAlias
|
||||
|
||||
__all__ = ["Client", "Listener", "Pipe", "wait"]
|
||||
|
||||
@@ -27,7 +27,7 @@ class _ConnectionBase:
|
||||
def recv_bytes_into(self, buf: Any, offset: int = 0) -> int: ...
|
||||
def recv(self) -> Any: ...
|
||||
def poll(self, timeout: float | None = 0.0) -> bool: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
|
||||
) -> None: ...
|
||||
@@ -47,7 +47,7 @@ class Listener:
|
||||
def address(self) -> _Address: ...
|
||||
@property
|
||||
def last_accepted(self) -> _Address | None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from _typeshed import Self
|
||||
from queue import Queue
|
||||
from types import TracebackType
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
__all__ = ["Client", "Listener", "Pipe"]
|
||||
|
||||
@@ -17,7 +16,7 @@ class Connection:
|
||||
recv_bytes: Any
|
||||
send: Any
|
||||
send_bytes: Any
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
@@ -29,7 +28,7 @@ class Listener:
|
||||
_backlog_queue: Queue[Any] | None
|
||||
@property
|
||||
def address(self) -> Queue[Any] | None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import queue
|
||||
import sys
|
||||
import threading
|
||||
from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
|
||||
from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
|
||||
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence
|
||||
from types import TracebackType
|
||||
from typing import Any, AnyStr, ClassVar, Generic, TypeVar, overload
|
||||
from typing_extensions import SupportsIndex, TypeAlias
|
||||
from typing_extensions import Self, SupportsIndex, TypeAlias
|
||||
|
||||
from .connection import Connection
|
||||
from .context import BaseContext
|
||||
@@ -116,8 +116,8 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
|
||||
def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ...
|
||||
|
||||
class ListProxy(BaseListProxy[_T]):
|
||||
def __iadd__(self: Self, __x: Iterable[_T]) -> Self: ... # type: ignore[override]
|
||||
def __imul__(self: Self, __n: SupportsIndex) -> Self: ... # type: ignore[override]
|
||||
def __iadd__(self, __x: Iterable[_T]) -> Self: ... # type: ignore[override]
|
||||
def __imul__(self, __n: SupportsIndex) -> Self: ... # type: ignore[override]
|
||||
|
||||
# Returned by BaseManager.get_server()
|
||||
class Server:
|
||||
@@ -165,7 +165,7 @@ class BaseManager:
|
||||
method_to_typeid: Mapping[str, str] | None = None,
|
||||
create_method: bool = True,
|
||||
) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from collections.abc import Callable, Iterable, Iterator, Mapping
|
||||
from types import TracebackType
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, Self
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -62,7 +61,7 @@ class IMapIterator(Iterator[_T]):
|
||||
else:
|
||||
def __init__(self, cache: dict[int, IMapIterator[Any]]) -> None: ...
|
||||
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def __iter__(self) -> Self: ...
|
||||
def next(self, timeout: float | None = None) -> _T: ...
|
||||
def __next__(self, timeout: float | None = None) -> _T: ...
|
||||
|
||||
@@ -109,7 +108,7 @@ class Pool:
|
||||
def close(self) -> None: ...
|
||||
def terminate(self) -> None: ...
|
||||
def join(self) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Generic, TypeVar, overload
|
||||
from typing_extensions import Self
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -29,7 +29,7 @@ class ShareableList(Generic[_SLT]):
|
||||
def __init__(self, sequence: Iterable[_SLT], *, name: str | None = None) -> None: ...
|
||||
def __getitem__(self, position: int) -> _SLT: ...
|
||||
def __setitem__(self, position: int, value: _SLT) -> None: ...
|
||||
def __reduce__(self: Self) -> tuple[Self, tuple[_SLT, ...]]: ...
|
||||
def __reduce__(self) -> tuple[Self, tuple[_SLT, ...]]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@property
|
||||
def format(self) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user