Skip to content

Commit

Permalink
More docs fixes (#3326)
Browse files Browse the repository at this point in the history
* 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 <117659936+vladvildanov@users.noreply.github.com>
  • Loading branch information
kurtmckee and vladvildanov committed Sep 27, 2024
1 parent 64a4053 commit 9fddc15
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 82 deletions.
10 changes: 6 additions & 4 deletions redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,12 @@ async def aclose(self, close_connection_pool: Optional[bool] = None) -> None:
"""
Closes Redis client connection
:param close_connection_pool: decides whether to close the connection pool used
by this Redis client, overriding Redis.auto_close_connection_pool. By default,
let Redis.auto_close_connection_pool decide whether to close the connection
pool.
Args:
close_connection_pool:
decides whether to close the connection pool used by this Redis client,
overriding Redis.auto_close_connection_pool.
By default, let Redis.auto_close_connection_pool decide
whether to close the connection pool.
"""
conn = self.connection
if conn:
Expand Down
59 changes: 36 additions & 23 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
from .helpers import list_or_args

if TYPE_CHECKING:
from redis.asyncio.client import Redis as AsyncRedis
from redis.client import Redis
import redis.asyncio.client
import redis.client


class ACLCommands(CommandsProtocol):
Expand Down Expand Up @@ -731,16 +731,19 @@ def client_pause(self, timeout: int, all: bool = True, **kwargs) -> ResponseT:
For more information see https://redis.io/commands/client-pause
:param timeout: milliseconds to pause clients
:param all: If true (default) all client commands are blocked.
otherwise, clients are only blocked if they attempt to execute
a write command.
Args:
timeout: milliseconds to pause clients
all: If true (default) all client commands are blocked.
otherwise, clients are only blocked if they attempt to execute
a write command.
For the WRITE mode, some commands have special behavior:
EVAL/EVALSHA: Will block client for all scripts.
PUBLISH: Will block client.
PFCOUNT: Will block client.
WAIT: Acknowledgments will be delayed, so this command will
appear blocked.
* EVAL/EVALSHA: Will block client for all scripts.
* PUBLISH: Will block client.
* PFCOUNT: Will block client.
* WAIT: Acknowledgments will be delayed, so this command will
appear blocked.
"""
args = ["CLIENT PAUSE", str(timeout)]
if not isinstance(timeout, int):
Expand Down Expand Up @@ -1439,7 +1442,7 @@ class BitFieldOperation:

def __init__(
self,
client: Union["Redis", "AsyncRedis"],
client: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
key: str,
default_overflow: Union[str, None] = None,
):
Expand Down Expand Up @@ -1583,7 +1586,7 @@ def bitcount(
return self.execute_command("BITCOUNT", *params, keys=[key])

def bitfield(
self: Union["Redis", "AsyncRedis"],
self: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
key: KeyT,
default_overflow: Union[str, None] = None,
) -> BitFieldOperation:
Expand All @@ -1596,7 +1599,7 @@ def bitfield(
return BitFieldOperation(self, key, default_overflow=default_overflow)

def bitfield_ro(
self: Union["Redis", "AsyncRedis"],
self: Union["redis.client.Redis", "redis.asyncio.client.Redis"],
key: KeyT,
encoding: str,
offset: BitfieldOffsetT,
Expand Down Expand Up @@ -5464,7 +5467,7 @@ class Script:
An executable Lua script object returned by ``register_script``
"""

def __init__(self, registered_client: "Redis", script: ScriptTextT):
def __init__(self, registered_client: "redis.client.Redis", script: ScriptTextT):
self.registered_client = registered_client
self.script = script
# Precalculate and store the SHA1 hex digest of the script.
Expand All @@ -5484,7 +5487,7 @@ def __call__(
self,
keys: Union[Sequence[KeyT], None] = None,
args: Union[Iterable[EncodableT], None] = None,
client: Union["Redis", None] = None,
client: Union["redis.client.Redis", None] = None,
):
"""Execute the script, passing any required ``args``"""
keys = keys or []
Expand Down Expand Up @@ -5513,7 +5516,11 @@ class AsyncScript:
An executable Lua script object returned by ``register_script``
"""

def __init__(self, registered_client: "AsyncRedis", script: ScriptTextT):
def __init__(
self,
registered_client: "redis.asyncio.client.Redis",
script: ScriptTextT,
):
self.registered_client = registered_client
self.script = script
# Precalculate and store the SHA1 hex digest of the script.
Expand All @@ -5533,7 +5540,7 @@ async def __call__(
self,
keys: Union[Sequence[KeyT], None] = None,
args: Union[Iterable[EncodableT], None] = None,
client: Union["AsyncRedis", None] = None,
client: Union["redis.asyncio.client.Redis", None] = None,
):
"""Execute the script, passing any required ``args``"""
keys = keys or []
Expand Down Expand Up @@ -5758,7 +5765,7 @@ def script_load(self, script: ScriptTextT) -> ResponseT:
"""
return self.execute_command("SCRIPT LOAD", script)

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

def register_script(self: "AsyncRedis", script: ScriptTextT) -> AsyncScript:
def register_script(
self: "redis.asyncio.client.Redis",
script: ScriptTextT,
) -> AsyncScript:
"""
Register a Lua ``script`` specifying the ``keys`` it will touch.
Returns a Script object that is callable and hides the complexity of
Expand Down Expand Up @@ -6415,9 +6425,12 @@ def function_list(
) -> Union[Awaitable[List], List]:
"""
Return information about the functions and libraries.
:param library: pecify a pattern for matching library names
:param withcode: cause the server to include the libraries source
implementation in the reply
Args:
library: specify a pattern for matching library names
withcode: cause the server to include the libraries source implementation
in the reply
"""
args = ["LIBRARYNAME", library]
if withcode:
Expand Down
110 changes: 55 additions & 55 deletions redis/commands/timeseries/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ def create(
duplicate_policy:
Policy for handling multiple samples with identical timestamps. Can be
one of:
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing
value.
- 'max': Only override if the value is higher than the existing
value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing value.
- 'max': Only override if the value is higher than the existing value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
ignore_max_time_diff:
A non-negative integer value, in milliseconds, that sets an ignore
threshold for added timestamps. If the difference between the last
Expand Down Expand Up @@ -130,17 +130,17 @@ def alter(
duplicate_policy:
Policy for handling multiple samples with identical timestamps. Can be
one of:
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing
value.
- 'max': Only override if the value is higher than the existing
value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing value.
- 'max': Only override if the value is higher than the existing value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
ignore_max_time_diff:
A non-negative integer value, in milliseconds, that sets an ignore
threshold for added timestamps. If the difference between the last
Expand Down Expand Up @@ -210,17 +210,17 @@ def add(
duplicate_policy:
Policy for handling multiple samples with identical timestamps. Can be
one of:
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing
value.
- 'max': Only override if the value is higher than the existing
value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing value.
- 'max': Only override if the value is higher than the existing value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
ignore_max_time_diff:
A non-negative integer value, in milliseconds, that sets an ignore
threshold for added timestamps. If the difference between the last
Expand Down Expand Up @@ -331,17 +331,17 @@ def incrby(
duplicate_policy:
Policy for handling multiple samples with identical timestamps. Can be
one of:
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing
value.
- 'max': Only override if the value is higher than the existing
value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing value.
- 'max': Only override if the value is higher than the existing value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
ignore_max_time_diff:
A non-negative integer value, in milliseconds, that sets an ignore
threshold for added timestamps. If the difference between the last
Expand Down Expand Up @@ -423,17 +423,17 @@ def decrby(
duplicate_policy:
Policy for handling multiple samples with identical timestamps. Can be
one of:
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing
value.
- 'max': Only override if the value is higher than the existing
value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
- 'block': An error will occur and the new value will be ignored.
- 'first': Ignore the new value.
- 'last': Override with the latest value.
- 'min': Only override if the value is lower than the existing value.
- 'max': Only override if the value is higher than the existing value.
- 'sum': If a previous sample exists, add the new sample to it so
that the updated value is equal to (previous + new). If no
previous sample exists, set the updated value equal to the new
value.
ignore_max_time_diff:
A non-negative integer value, in milliseconds, that sets an ignore
threshold for added timestamps. If the difference between the last
Expand Down

0 comments on commit 9fddc15

Please sign in to comment.