-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Refactor(Typing): Add and update type annotations for core Redis commands #3281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
31a4cf4
0e1002c
c0c88a0
07744ab
abc67d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# from __future__ import annotations | ||
|
||
from datetime import datetime, timedelta | ||
from typing import ( | ||
TYPE_CHECKING, | ||
Any, | ||
Awaitable, | ||
Iterable, | ||
List, | ||
Literal, | ||
Mapping, | ||
Protocol, | ||
Type, | ||
|
@@ -32,7 +32,14 @@ | |
PatternT = _StringLikeT # Patterns matched against keys, fields etc | ||
FieldT = EncodableT # Fields within hash tables, streams and geo commands | ||
KeysT = Union[KeyT, Iterable[KeyT]] | ||
ResponseT = Union[Awaitable[Any], Any] | ||
OldResponseT = Union[Awaitable[Any], Any] # Deprecated | ||
AnyResponseT = TypeVar("AnyResponseT", bound=Any) | ||
ResponseT = Union[AnyResponseT, Awaitable[AnyResponseT]] | ||
OKT = Literal[True] | ||
ArrayResponseT = List | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two aspects here. First, Second, why define aliases to single types? You can just use |
||
IntegerResponseT = int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same point here, just use |
||
NullResponseT = type(None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems not used at all. |
||
BulkStringResponseT = str | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for clarity, it isn't just any |
||
ChannelT = _StringLikeT | ||
GroupT = _StringLikeT # Consumer group | ||
ConsumerT = _StringLikeT # Consumer name | ||
|
@@ -54,8 +61,10 @@ | |
class CommandsProtocol(Protocol): | ||
connection_pool: Union["AsyncConnectionPool", "ConnectionPool"] | ||
|
||
def execute_command(self, *args, **options) -> ResponseT: ... | ||
def execute_command(self, *args, **options) -> ResponseT[Any]: ... | ||
|
||
|
||
class ClusterCommandsProtocol(CommandsProtocol): | ||
encoder: "Encoder" | ||
|
||
def execute_command(self, *args, **options) -> ResponseT[Any]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anymore, I would say just get rid of it.