Skip to content

Change type hints with possible None args or return types to be annotated with Optional - includes commands in core.py and json commands #3610

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

Merged
merged 14 commits into from
May 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(redis-client): replace Optional[None] with Optional[int] for nume…
…ric parameters
  • Loading branch information
kesha1225 committed Apr 25, 2025
commit 8df197c5e1b3baee6f7f3a98b13b1f1c04fa2756
106 changes: 53 additions & 53 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def acl_deluser(self, *username: str, **kwargs) -> ResponseT:
"""
return self.execute_command("ACL DELUSER", *username, **kwargs)

def acl_genpass(self, bits: Optional[None] = None, **kwargs) -> ResponseT:
def acl_genpass(self, bits: Optional[int] = None, **kwargs) -> ResponseT:
"""Generate a random password value.
If ``bits`` is supplied then use this number of bits, rounded to
the next multiple of 4.
Expand Down Expand Up @@ -1304,7 +1304,7 @@ def slaveof(
return self.execute_command("SLAVEOF", b"NO", b"ONE", **kwargs)
return self.execute_command("SLAVEOF", host, port, **kwargs)

def slowlog_get(self, num: Optional[None] = None, **kwargs) -> ResponseT:
def slowlog_get(self, num: Optional[int] = None, **kwargs) -> ResponseT:
"""
Get the entries from the slowlog. If ``num`` is specified, get the
most recent ``num`` items.
Expand Down Expand Up @@ -1572,8 +1572,8 @@ def append(self, key: KeyT, value: EncodableT) -> ResponseT:
def bitcount(
self,
key: KeyT,
start: Optional[None] = None,
end: Optional[None] = None,
start: Optional[int] = None,
end: Optional[int] = None,
mode: Optional[str] = None,
) -> ResponseT:
"""
Expand Down Expand Up @@ -1641,8 +1641,8 @@ def bitpos(
self,
key: KeyT,
bit: int,
start: Optional[None] = None,
end: Optional[None] = None,
start: Optional[int] = None,
end: Optional[int] = None,
mode: Optional[str] = None,
) -> ResponseT:
"""
Expand Down Expand Up @@ -2191,8 +2191,8 @@ def restore(
value: EncodableT,
replace: bool = False,
absttl: bool = False,
idletime: Optional[None] = None,
frequency: Optional[None] = None,
idletime: Optional[int] = None,
frequency: Optional[int] = None,
) -> ResponseT:
"""
Create a key using the provided serialized value, previously obtained
Expand Down Expand Up @@ -2360,7 +2360,7 @@ def stralgo(
specific_argument: Union[Literal["strings"], Literal["keys"]] = "strings",
len: bool = False,
idx: bool = False,
minmatchlen: Optional[None] = None,
minmatchlen: Optional[int] = None,
withmatchlen: bool = False,
**kwargs,
) -> ResponseT:
Expand Down Expand Up @@ -2960,7 +2960,7 @@ def scan(
self,
cursor: int = 0,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
_type: Optional[str] = None,
**kwargs,
) -> ResponseT:
Expand Down Expand Up @@ -2992,7 +2992,7 @@ def scan(
def scan_iter(
self,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
_type: Optional[str] = None,
**kwargs,
) -> Iterator:
Expand Down Expand Up @@ -3022,7 +3022,7 @@ def sscan(
name: KeyT,
cursor: int = 0,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
) -> ResponseT:
"""
Incrementally return lists of elements in a set. Also return a cursor
Expand All @@ -3045,7 +3045,7 @@ def sscan_iter(
self,
name: KeyT,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
) -> Iterator:
"""
Make an iterator using the SSCAN command so that the client doesn't
Expand All @@ -3065,7 +3065,7 @@ def hscan(
name: KeyT,
cursor: int = 0,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
no_values: Union[bool, None] = None,
) -> ResponseT:
"""
Expand Down Expand Up @@ -3093,7 +3093,7 @@ def hscan_iter(
self,
name: str,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
no_values: Union[bool, None] = None,
) -> Iterator:
"""
Expand Down Expand Up @@ -3121,7 +3121,7 @@ def zscan(
name: KeyT,
cursor: int = 0,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
score_cast_func: Union[type, Callable] = float,
) -> ResponseT:
"""
Expand All @@ -3148,7 +3148,7 @@ def zscan_iter(
self,
name: KeyT,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
score_cast_func: Union[type, Callable] = float,
) -> Iterator:
"""
Expand Down Expand Up @@ -3177,7 +3177,7 @@ class AsyncScanCommands(ScanCommands):
async def scan_iter(
self,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
_type: Optional[str] = None,
**kwargs,
) -> AsyncIterator:
Expand Down Expand Up @@ -3207,7 +3207,7 @@ async def sscan_iter(
self,
name: KeyT,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
) -> AsyncIterator:
"""
Make an iterator using the SSCAN command so that the client doesn't
Expand All @@ -3229,7 +3229,7 @@ async def hscan_iter(
self,
name: str,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
no_values: Union[bool, None] = None,
) -> AsyncIterator:
"""
Expand Down Expand Up @@ -3258,7 +3258,7 @@ async def zscan_iter(
self,
name: KeyT,
match: Union[PatternT, None] = None,
count: Optional[None] = None,
count: Optional[int] = None,
score_cast_func: Union[type, Callable] = float,
) -> AsyncIterator:
"""
Expand Down Expand Up @@ -3489,11 +3489,11 @@ def xadd(
name: KeyT,
fields: Dict[FieldT, EncodableT],
id: StreamIdT = "*",
maxlen: Optional[None] = None,
maxlen: Optional[int] = None,
approximate: bool = True,
nomkstream: bool = False,
minid: Union[StreamIdT, None] = None,
limit: Optional[None] = None,
limit: Optional[int] = None,
) -> ResponseT:
"""
Add to a stream.
Expand Down Expand Up @@ -3544,7 +3544,7 @@ def xautoclaim(
consumername: ConsumerT,
min_idle_time: int,
start_id: StreamIdT = "0-0",
count: Optional[None] = None,
count: Optional[int] = None,
justid: bool = False,
) -> ResponseT:
"""
Expand Down Expand Up @@ -3595,9 +3595,9 @@ def xclaim(
consumername: ConsumerT,
min_idle_time: int,
message_ids: Union[List[StreamIdT], Tuple[StreamIdT]],
idle: Optional[None] = None,
time: Optional[None] = None,
retrycount: Optional[None] = None,
idle: Optional[int] = None,
time: Optional[int] = None,
retrycount: Optional[int] = None,
force: bool = False,
justid: bool = False,
) -> ResponseT:
Expand Down Expand Up @@ -3829,7 +3829,7 @@ def xpending_range(
max: StreamIdT,
count: int,
consumername: Union[ConsumerT, None] = None,
idle: Optional[None] = None,
idle: Optional[int] = None,
) -> ResponseT:
"""
Returns information about pending messages, in a range.
Expand Down Expand Up @@ -3883,7 +3883,7 @@ def xrange(
name: KeyT,
min: StreamIdT = "-",
max: StreamIdT = "+",
count: Optional[None] = None,
count: Optional[int] = None,
) -> ResponseT:
"""
Read stream values within an interval.
Expand Down Expand Up @@ -3913,8 +3913,8 @@ def xrange(
def xread(
self,
streams: Dict[KeyT, StreamIdT],
count: Optional[None] = None,
block: Optional[None] = None,
count: Optional[int] = None,
block: Optional[int] = None,
) -> ResponseT:
"""
Block and monitor multiple streams for new data.
Expand Down Expand Up @@ -3953,8 +3953,8 @@ def xreadgroup(
groupname: str,
consumername: str,
streams: Dict[KeyT, StreamIdT],
count: Optional[None] = None,
block: Optional[None] = None,
count: Optional[int] = None,
block: Optional[int] = None,
noack: bool = False,
) -> ResponseT:
"""
Expand Down Expand Up @@ -4000,7 +4000,7 @@ def xrevrange(
name: KeyT,
max: StreamIdT = "+",
min: StreamIdT = "-",
count: Optional[None] = None,
count: Optional[int] = None,
) -> ResponseT:
"""
Read stream values within an interval, in reverse order.
Expand Down Expand Up @@ -4030,10 +4030,10 @@ def xrevrange(
def xtrim(
self,
name: KeyT,
maxlen: Optional[None] = None,
maxlen: Optional[int] = None,
approximate: bool = True,
minid: Union[StreamIdT, None] = None,
limit: Optional[None] = None,
limit: Optional[int] = None,
) -> ResponseT:
"""
Trims old messages from a stream.
Expand Down Expand Up @@ -4263,7 +4263,7 @@ def zlexcount(self, name, min, max):
"""
return self.execute_command("ZLEXCOUNT", name, min, max, keys=[name])

def zpopmax(self, name: KeyT, count: Optional[None] = None) -> ResponseT:
def zpopmax(self, name: KeyT, count: Optional[int] = None) -> ResponseT:
"""
Remove and return up to ``count`` members with the highest scores
from the sorted set ``name``.
Expand All @@ -4274,7 +4274,7 @@ def zpopmax(self, name: KeyT, count: Optional[None] = None) -> ResponseT:
options = {"withscores": True}
return self.execute_command("ZPOPMAX", name, *args, **options)

def zpopmin(self, name: KeyT, count: Optional[None] = None) -> ResponseT:
def zpopmin(self, name: KeyT, count: Optional[int] = None) -> ResponseT:
"""
Remove and return up to ``count`` members with the lowest scores
from the sorted set ``name``.
Expand Down Expand Up @@ -4418,8 +4418,8 @@ def _zrange(
bylex: bool = False,
withscores: bool = False,
score_cast_func: Union[type, Callable, None] = float,
offset: Optional[None] = None,
num: Optional[None] = None,
offset: Optional[int] = None,
num: Optional[int] = None,
) -> ResponseT:
if byscore and bylex:
raise DataError("``byscore`` and ``bylex`` can not be specified together.")
Expand Down Expand Up @@ -4545,8 +4545,8 @@ def zrangestore(
byscore: bool = False,
bylex: bool = False,
desc: bool = False,
offset: Optional[None] = None,
num: Optional[None] = None,
offset: Optional[int] = None,
num: Optional[int] = None,
) -> ResponseT:
"""
Stores in ``dest`` the result of a range of values from sorted set
Expand Down Expand Up @@ -4591,8 +4591,8 @@ def zrangebylex(
name: KeyT,
min: EncodableT,
max: EncodableT,
start: Optional[None] = None,
num: Optional[None] = None,
start: Optional[int] = None,
num: Optional[int] = None,
) -> ResponseT:
"""
Return the lexicographical range of values from sorted set ``name``
Expand All @@ -4615,8 +4615,8 @@ def zrevrangebylex(
name: KeyT,
max: EncodableT,
min: EncodableT,
start: Optional[None] = None,
num: Optional[None] = None,
start: Optional[int] = None,
num: Optional[int] = None,
) -> ResponseT:
"""
Return the reversed lexicographical range of values from sorted set
Expand All @@ -4639,8 +4639,8 @@ def zrangebyscore(
name: KeyT,
min: ZScoreBoundT,
max: ZScoreBoundT,
start: Optional[None] = None,
num: Optional[None] = None,
start: Optional[int] = None,
num: Optional[int] = None,
withscores: bool = False,
score_cast_func: Union[type, Callable] = float,
) -> ResponseT:
Expand Down Expand Up @@ -4674,8 +4674,8 @@ def zrevrangebyscore(
name: KeyT,
max: ZScoreBoundT,
min: ZScoreBoundT,
start: Optional[None] = None,
num: Optional[None] = None,
start: Optional[int] = None,
num: Optional[int] = None,
withscores: bool = False,
score_cast_func: Union[type, Callable] = float,
):
Expand Down Expand Up @@ -6040,7 +6040,7 @@ def georadius(
withdist: bool = False,
withcoord: bool = False,
withhash: bool = False,
count: Optional[None] = None,
count: Optional[int] = None,
sort: Optional[str] = None,
store: Optional[KeyT] = None,
store_dist: Optional[KeyT] = None,
Expand Down Expand Up @@ -6102,7 +6102,7 @@ def georadiusbymember(
withdist: bool = False,
withcoord: bool = False,
withhash: bool = False,
count: Optional[None] = None,
count: Optional[int] = None,
sort: Optional[str] = None,
store: Union[KeyT, None] = None,
store_dist: Union[KeyT, None] = None,
Expand Down Expand Up @@ -6189,7 +6189,7 @@ def geosearch(
width: Union[float, None] = None,
height: Union[float, None] = None,
sort: Optional[str] = None,
count: Optional[None] = None,
count: Optional[int] = None,
any: bool = False,
withcoord: bool = False,
withdist: bool = False,
Expand Down
Loading