Skip to content

Commit e4ce4a4

Browse files
More docs fixes (#3326)
* Docs: Resolve 'Unexpected indentation' warnings * Docs: Resolve 'Unexpected unindent' warnings * Docs: Resolve "more than one target for cross-reference 'Redis'" warnings When Sphinx runs, `TYPE_CHECKING` is not enabled, so the differentiating sync/async `Redis` imports don't happen, and Sphinx appears to be unable to infer which class `"Redis"` should cross-reference. --------- Co-authored-by: Vladyslav Vildanov <[email protected]>
1 parent 8f1dc81 commit e4ce4a4

File tree

3 files changed

+97
-82
lines changed

3 files changed

+97
-82
lines changed

redis/asyncio/client.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,12 @@ async def aclose(self, close_connection_pool: Optional[bool] = None) -> None:
575575
"""
576576
Closes Redis client connection
577577
578-
:param close_connection_pool: decides whether to close the connection pool used
579-
by this Redis client, overriding Redis.auto_close_connection_pool. By default,
580-
let Redis.auto_close_connection_pool decide whether to close the connection
581-
pool.
578+
Args:
579+
close_connection_pool:
580+
decides whether to close the connection pool used by this Redis client,
581+
overriding Redis.auto_close_connection_pool.
582+
By default, let Redis.auto_close_connection_pool decide
583+
whether to close the connection pool.
582584
"""
583585
conn = self.connection
584586
if conn:

redis/commands/core.py

+36-23
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
from .helpers import list_or_args
4747

4848
if TYPE_CHECKING:
49-
from redis.asyncio.client import Redis as AsyncRedis
50-
from redis.client import Redis
49+
import redis.asyncio.client
50+
import redis.client
5151

5252

5353
class ACLCommands(CommandsProtocol):
@@ -731,16 +731,19 @@ def client_pause(self, timeout: int, all: bool = True, **kwargs) -> ResponseT:
731731
732732
For more information see https://redis.io/commands/client-pause
733733
734-
:param timeout: milliseconds to pause clients
735-
:param all: If true (default) all client commands are blocked.
736-
otherwise, clients are only blocked if they attempt to execute
737-
a write command.
734+
Args:
735+
timeout: milliseconds to pause clients
736+
all: If true (default) all client commands are blocked.
737+
otherwise, clients are only blocked if they attempt to execute
738+
a write command.
739+
738740
For the WRITE mode, some commands have special behavior:
739-
EVAL/EVALSHA: Will block client for all scripts.
740-
PUBLISH: Will block client.
741-
PFCOUNT: Will block client.
742-
WAIT: Acknowledgments will be delayed, so this command will
743-
appear blocked.
741+
742+
* EVAL/EVALSHA: Will block client for all scripts.
743+
* PUBLISH: Will block client.
744+
* PFCOUNT: Will block client.
745+
* WAIT: Acknowledgments will be delayed, so this command will
746+
appear blocked.
744747
"""
745748
args = ["CLIENT PAUSE", str(timeout)]
746749
if not isinstance(timeout, int):
@@ -1439,7 +1442,7 @@ class BitFieldOperation:
14391442

14401443
def __init__(
14411444
self,
1442-
client: Union["Redis", "AsyncRedis"],
1445+
client: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
14431446
key: str,
14441447
default_overflow: Union[str, None] = None,
14451448
):
@@ -1583,7 +1586,7 @@ def bitcount(
15831586
return self.execute_command("BITCOUNT", *params, keys=[key])
15841587

15851588
def bitfield(
1586-
self: Union["Redis", "AsyncRedis"],
1589+
self: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
15871590
key: KeyT,
15881591
default_overflow: Union[str, None] = None,
15891592
) -> BitFieldOperation:
@@ -1596,7 +1599,7 @@ def bitfield(
15961599
return BitFieldOperation(self, key, default_overflow=default_overflow)
15971600

15981601
def bitfield_ro(
1599-
self: Union["Redis", "AsyncRedis"],
1602+
self: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
16001603
key: KeyT,
16011604
encoding: str,
16021605
offset: BitfieldOffsetT,
@@ -5464,7 +5467,7 @@ class Script:
54645467
An executable Lua script object returned by ``register_script``
54655468
"""
54665469

5467-
def __init__(self, registered_client: "Redis", script: ScriptTextT):
5470+
def __init__(self, registered_client: "redis.client.Redis", script: ScriptTextT):
54685471
self.registered_client = registered_client
54695472
self.script = script
54705473
# Precalculate and store the SHA1 hex digest of the script.
@@ -5484,7 +5487,7 @@ def __call__(
54845487
self,
54855488
keys: Union[Sequence[KeyT], None] = None,
54865489
args: Union[Iterable[EncodableT], None] = None,
5487-
client: Union["Redis", None] = None,
5490+
client: Union["redis.client.Redis", None] = None,
54885491
):
54895492
"""Execute the script, passing any required ``args``"""
54905493
keys = keys or []
@@ -5513,7 +5516,11 @@ class AsyncScript:
55135516
An executable Lua script object returned by ``register_script``
55145517
"""
55155518

5516-
def __init__(self, registered_client: "AsyncRedis", script: ScriptTextT):
5519+
def __init__(
5520+
self,
5521+
registered_client: "redis.asyncio.client.Redis",
5522+
script: ScriptTextT,
5523+
):
55175524
self.registered_client = registered_client
55185525
self.script = script
55195526
# Precalculate and store the SHA1 hex digest of the script.
@@ -5533,7 +5540,7 @@ async def __call__(
55335540
self,
55345541
keys: Union[Sequence[KeyT], None] = None,
55355542
args: Union[Iterable[EncodableT], None] = None,
5536-
client: Union["AsyncRedis", None] = None,
5543+
client: Union["redis.asyncio.client.Redis", None] = None,
55375544
):
55385545
"""Execute the script, passing any required ``args``"""
55395546
keys = keys or []
@@ -5758,7 +5765,7 @@ def script_load(self, script: ScriptTextT) -> ResponseT:
57585765
"""
57595766
return self.execute_command("SCRIPT LOAD", script)
57605767

5761-
def register_script(self: "Redis", script: ScriptTextT) -> Script:
5768+
def register_script(self: "redis.client.Redis", script: ScriptTextT) -> Script:
57625769
"""
57635770
Register a Lua ``script`` specifying the ``keys`` it will touch.
57645771
Returns a Script object that is callable and hides the complexity of
@@ -5772,7 +5779,10 @@ class AsyncScriptCommands(ScriptCommands):
57725779
async def script_debug(self, *args) -> None:
57735780
return super().script_debug()
57745781

5775-
def register_script(self: "AsyncRedis", script: ScriptTextT) -> AsyncScript:
5782+
def register_script(
5783+
self: "redis.asyncio.client.Redis",
5784+
script: ScriptTextT,
5785+
) -> AsyncScript:
57765786
"""
57775787
Register a Lua ``script`` specifying the ``keys`` it will touch.
57785788
Returns a Script object that is callable and hides the complexity of
@@ -6415,9 +6425,12 @@ def function_list(
64156425
) -> Union[Awaitable[List], List]:
64166426
"""
64176427
Return information about the functions and libraries.
6418-
:param library: pecify a pattern for matching library names
6419-
:param withcode: cause the server to include the libraries source
6420-
implementation in the reply
6428+
6429+
Args:
6430+
6431+
library: specify a pattern for matching library names
6432+
withcode: cause the server to include the libraries source implementation
6433+
in the reply
64216434
"""
64226435
args = ["LIBRARYNAME", library]
64236436
if withcode:

redis/commands/timeseries/commands.py

+55-55
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ def create(
6060
duplicate_policy:
6161
Policy for handling multiple samples with identical timestamps. Can be
6262
one of:
63-
- 'block': An error will occur and the new value will be ignored.
64-
- 'first': Ignore the new value.
65-
- 'last': Override with the latest value.
66-
- 'min': Only override if the value is lower than the existing
67-
value.
68-
- 'max': Only override if the value is higher than the existing
69-
value.
70-
- 'sum': If a previous sample exists, add the new sample to it so
71-
that the updated value is equal to (previous + new). If no
72-
previous sample exists, set the updated value equal to the new
73-
value.
63+
64+
- 'block': An error will occur and the new value will be ignored.
65+
- 'first': Ignore the new value.
66+
- 'last': Override with the latest value.
67+
- 'min': Only override if the value is lower than the existing value.
68+
- 'max': Only override if the value is higher than the existing value.
69+
- 'sum': If a previous sample exists, add the new sample to it so
70+
that the updated value is equal to (previous + new). If no
71+
previous sample exists, set the updated value equal to the new
72+
value.
73+
7474
ignore_max_time_diff:
7575
A non-negative integer value, in milliseconds, that sets an ignore
7676
threshold for added timestamps. If the difference between the last
@@ -130,17 +130,17 @@ def alter(
130130
duplicate_policy:
131131
Policy for handling multiple samples with identical timestamps. Can be
132132
one of:
133-
- 'block': An error will occur and the new value will be ignored.
134-
- 'first': Ignore the new value.
135-
- 'last': Override with the latest value.
136-
- 'min': Only override if the value is lower than the existing
137-
value.
138-
- 'max': Only override if the value is higher than the existing
139-
value.
140-
- 'sum': If a previous sample exists, add the new sample to it so
141-
that the updated value is equal to (previous + new). If no
142-
previous sample exists, set the updated value equal to the new
143-
value.
133+
134+
- 'block': An error will occur and the new value will be ignored.
135+
- 'first': Ignore the new value.
136+
- 'last': Override with the latest value.
137+
- 'min': Only override if the value is lower than the existing value.
138+
- 'max': Only override if the value is higher than the existing value.
139+
- 'sum': If a previous sample exists, add the new sample to it so
140+
that the updated value is equal to (previous + new). If no
141+
previous sample exists, set the updated value equal to the new
142+
value.
143+
144144
ignore_max_time_diff:
145145
A non-negative integer value, in milliseconds, that sets an ignore
146146
threshold for added timestamps. If the difference between the last
@@ -210,17 +210,17 @@ def add(
210210
duplicate_policy:
211211
Policy for handling multiple samples with identical timestamps. Can be
212212
one of:
213-
- 'block': An error will occur and the new value will be ignored.
214-
- 'first': Ignore the new value.
215-
- 'last': Override with the latest value.
216-
- 'min': Only override if the value is lower than the existing
217-
value.
218-
- 'max': Only override if the value is higher than the existing
219-
value.
220-
- 'sum': If a previous sample exists, add the new sample to it so
221-
that the updated value is equal to (previous + new). If no
222-
previous sample exists, set the updated value equal to the new
223-
value.
213+
214+
- 'block': An error will occur and the new value will be ignored.
215+
- 'first': Ignore the new value.
216+
- 'last': Override with the latest value.
217+
- 'min': Only override if the value is lower than the existing value.
218+
- 'max': Only override if the value is higher than the existing value.
219+
- 'sum': If a previous sample exists, add the new sample to it so
220+
that the updated value is equal to (previous + new). If no
221+
previous sample exists, set the updated value equal to the new
222+
value.
223+
224224
ignore_max_time_diff:
225225
A non-negative integer value, in milliseconds, that sets an ignore
226226
threshold for added timestamps. If the difference between the last
@@ -331,17 +331,17 @@ def incrby(
331331
duplicate_policy:
332332
Policy for handling multiple samples with identical timestamps. Can be
333333
one of:
334-
- 'block': An error will occur and the new value will be ignored.
335-
- 'first': Ignore the new value.
336-
- 'last': Override with the latest value.
337-
- 'min': Only override if the value is lower than the existing
338-
value.
339-
- 'max': Only override if the value is higher than the existing
340-
value.
341-
- 'sum': If a previous sample exists, add the new sample to it so
342-
that the updated value is equal to (previous + new). If no
343-
previous sample exists, set the updated value equal to the new
344-
value.
334+
335+
- 'block': An error will occur and the new value will be ignored.
336+
- 'first': Ignore the new value.
337+
- 'last': Override with the latest value.
338+
- 'min': Only override if the value is lower than the existing value.
339+
- 'max': Only override if the value is higher than the existing value.
340+
- 'sum': If a previous sample exists, add the new sample to it so
341+
that the updated value is equal to (previous + new). If no
342+
previous sample exists, set the updated value equal to the new
343+
value.
344+
345345
ignore_max_time_diff:
346346
A non-negative integer value, in milliseconds, that sets an ignore
347347
threshold for added timestamps. If the difference between the last
@@ -423,17 +423,17 @@ def decrby(
423423
duplicate_policy:
424424
Policy for handling multiple samples with identical timestamps. Can be
425425
one of:
426-
- 'block': An error will occur and the new value will be ignored.
427-
- 'first': Ignore the new value.
428-
- 'last': Override with the latest value.
429-
- 'min': Only override if the value is lower than the existing
430-
value.
431-
- 'max': Only override if the value is higher than the existing
432-
value.
433-
- 'sum': If a previous sample exists, add the new sample to it so
434-
that the updated value is equal to (previous + new). If no
435-
previous sample exists, set the updated value equal to the new
436-
value.
426+
427+
- 'block': An error will occur and the new value will be ignored.
428+
- 'first': Ignore the new value.
429+
- 'last': Override with the latest value.
430+
- 'min': Only override if the value is lower than the existing value.
431+
- 'max': Only override if the value is higher than the existing value.
432+
- 'sum': If a previous sample exists, add the new sample to it so
433+
that the updated value is equal to (previous + new). If no
434+
previous sample exists, set the updated value equal to the new
435+
value.
436+
437437
ignore_max_time_diff:
438438
A non-negative integer value, in milliseconds, that sets an ignore
439439
threshold for added timestamps. If the difference between the last

0 commit comments

Comments
 (0)