Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions
+7 -7
View File
@@ -1,8 +1,8 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Mapping, MutableMapping, Sequence
from datetime import datetime, timedelta
from typing import Any, ClassVar, Generic, NoReturn, Protocol, overload
from typing_extensions import Literal, TypeAlias, TypedDict
from typing_extensions import Literal, Self, TypeAlias, TypedDict
from redis import RedisError
from redis.asyncio.connection import ConnectCallbackT, Connection, ConnectionPool
@@ -67,7 +67,7 @@ class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], Asy
credential_provider: CredentialProvider | None = ...,
) -> None: ...
def __await__(self): ...
async def initialize(self: Self) -> Self: ...
async def initialize(self) -> Self: ...
def set_response_callback(self, command: str, callback: ResponseCallbackT): ...
def load_external_module(self, funcname, func) -> None: ...
def pipeline(self, transaction: bool = ..., shard_hint: str | None = ...) -> Pipeline[_StrType]: ...
@@ -92,7 +92,7 @@ class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], Asy
def pubsub(self, **kwargs) -> PubSub: ...
def monitor(self) -> Monitor: ...
def client(self) -> Redis[_StrType]: ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, exc_type, exc_value, traceback) -> None: ...
def __del__(self, _warnings: Any = ...) -> None: ...
async def close(self, close_connection_pool: bool | None = ...) -> None: ...
@@ -116,7 +116,7 @@ class Monitor:
connection: Any
def __init__(self, connection_pool: ConnectionPool) -> None: ...
async def connect(self) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, *args) -> None: ...
async def next_command(self) -> MonitorCommandInfo: ...
def listen(self) -> AsyncIterator[MonitorCommandInfo]: ...
@@ -142,7 +142,7 @@ class PubSub:
ignore_subscribe_messages: bool = ...,
encoder: Incomplete | None = ...,
) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, exc_type, exc_value, traceback) -> None: ...
def __del__(self) -> None: ...
async def reset(self) -> None: ...
@@ -191,7 +191,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
transaction: bool,
shard_hint: str | None,
) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, exc_type, exc_value, traceback) -> None: ...
def __await__(self): ...
def __len__(self) -> int: ...
+12 -11
View File
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Awaitable, Callable, Mapping
from typing import Any, Generic
from typing_extensions import Self
from redis.asyncio.client import ResponseCallbackT
from redis.asyncio.connection import BaseParser, Connection, Encoder
@@ -72,11 +73,11 @@ class RedisCluster(AbstractRedis, AbstractRedisCluster, Generic[_StrType]): # T
ssl_check_hostname: bool = ...,
ssl_keyfile: str | None = ...,
) -> None: ...
async def initialize(self: Self) -> Self: ...
async def initialize(self) -> Self: ...
async def close(self) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ...
def __await__(self: Self) -> Awaitable[Self]: ...
def __await__(self) -> Awaitable[Self]: ...
def __del__(self) -> None: ...
async def on_connect(self, connection: Connection) -> None: ...
def get_nodes(self) -> list[ClusterNode]: ...
@@ -94,7 +95,7 @@ class RedisCluster(AbstractRedis, AbstractRedisCluster, Generic[_StrType]): # T
async def execute_command(self, *args: EncodableT, **kwargs: Any) -> Any: ...
def pipeline(self, transaction: Any | None = ..., shard_hint: Any | None = ...) -> ClusterPipeline[_StrType]: ...
@classmethod
def from_url(cls: type[Self], url: str, **kwargs) -> Self: ...
def from_url(cls, url: str, **kwargs) -> Self: ...
class ClusterNode:
host: str
@@ -143,17 +144,17 @@ class NodesManager:
class ClusterPipeline(AbstractRedis, AbstractRedisCluster, Generic[_StrType]): # TODO: AsyncRedisClusterCommands
def __init__(self, client: RedisCluster[_StrType]) -> None: ...
async def initialize(self: Self) -> Self: ...
async def __aenter__(self: Self) -> Self: ...
async def initialize(self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ...
def __await__(self: Self) -> Awaitable[Self]: ...
def __enter__(self: Self) -> Self: ...
def __await__(self) -> Awaitable[Self]: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
def execute_command(self: Self, *args: KeyT | EncodableT, **kwargs: Any) -> Self: ...
def execute_command(self, *args: KeyT | EncodableT, **kwargs: Any) -> Self: ...
async def execute(self, raise_on_error: bool = ..., allow_redirections: bool = ...) -> list[Any]: ...
def mset_nonatomic(self: Self, mapping: Mapping[AnyKeyT, EncodableT]) -> Self: ...
def mset_nonatomic(self, mapping: Mapping[AnyKeyT, EncodableT]) -> Self: ...
class PipelineCommand:
args: Any
+2 -2
View File
@@ -1,8 +1,8 @@
import threading
from _typeshed import Self
from collections.abc import Awaitable
from types import SimpleNamespace, TracebackType
from typing import Any, ClassVar
from typing_extensions import Self
from redis.asyncio import Redis
from redis.commands.core import AsyncScript
@@ -33,7 +33,7 @@ class Lock:
thread_local: bool = ...,
) -> None: ...
def register_scripts(self) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
+4 -4
View File
@@ -1,11 +1,11 @@
import threading
from _typeshed import Incomplete, Self, SupportsItems
from _typeshed import Incomplete, SupportsItems
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from datetime import datetime, timedelta
from re import Pattern
from types import TracebackType
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
from redis import RedisError
@@ -340,7 +340,7 @@ class PubSub:
ignore_subscribe_messages: bool = ...,
encoder: Incomplete | None = ...,
) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...
@@ -726,7 +726,7 @@ class Monitor:
command_re: Pattern[str]
monitor_re: Pattern[str]
def __init__(self, connection_pool) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def next_command(self) -> dict[str, Any]: ...
def listen(self) -> Iterable[dict[str, Any]]: ...
+4 -4
View File
@@ -1,9 +1,9 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Callable, Iterable, Sequence
from threading import Lock
from types import TracebackType
from typing import Any, ClassVar, Generic, NoReturn, Protocol
from typing_extensions import Literal
from typing_extensions import Literal, Self
from redis.client import CaseInsensitiveDict, PubSub, Redis, _ParseResponseOptions
from redis.commands import CommandsParser, RedisClusterCommands
@@ -71,14 +71,14 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType], Generic
url: str | None = ...,
**kwargs,
) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def __del__(self) -> None: ...
def disconnect_connection_pools(self) -> None: ...
@classmethod
def from_url(cls: type[Self], url: str, **kwargs) -> Self: ...
def from_url(cls, url: str, **kwargs) -> Self: ...
def on_connect(self, connection: Connection) -> None: ...
def get_redis_connection(self, node: ClusterNode) -> Redis[Any]: ...
def get_node(
+3 -3
View File
@@ -1,9 +1,9 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Callable, Iterable, Mapping
from queue import Queue
from socket import socket
from typing import Any, ClassVar
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias
from .credentials import CredentialProvider
from .retry import Retry
@@ -202,7 +202,7 @@ class ConnectionPool:
max_connections: int
pid: int
@classmethod
def from_url(cls: type[Self], url: str, *, db: int = ..., decode_components: bool = ..., **kwargs) -> Self: ...
def from_url(cls, url: str, *, db: int = ..., decode_components: bool = ..., **kwargs) -> Self: ...
def __init__(
self, connection_class: type[Connection] = ..., max_connections: int | None = ..., **connection_kwargs
) -> None: ...
+3 -2
View File
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from types import TracebackType
from typing import Any, ClassVar, Protocol
from typing_extensions import Self
from redis.client import Redis
@@ -26,7 +27,7 @@ class Lock:
thread_local: bool = ...,
) -> None: ...
def register_scripts(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...