Skip to content

Commit 10b4caf

Browse files
authored
Merge branch 'master' into rm-duplicate-Script-class-issue-3332
2 parents cb4d8a7 + 77e09b7 commit 10b4caf

File tree

6 files changed

+104
-87
lines changed

6 files changed

+104
-87
lines changed

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ invoke==2.2.0
88
mock
99
packaging>=20.4
1010
pytest
11-
pytest-asyncio
11+
pytest-asyncio>=0.23.0,<0.24.0
1212
pytest-cov
1313
pytest-profiling
1414
pytest-timeout

redis/_parsers/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,11 @@ def parse_cluster_info(response, **options):
445445
def _parse_node_line(line):
446446
line_items = line.split(" ")
447447
node_id, addr, flags, master_id, ping, pong, epoch, connected = line.split(" ")[:8]
448-
addr = addr.split("@")[0]
448+
ip = addr.split("@")[0]
449+
hostname = addr.split("@")[1].split(",")[1] if "@" in addr and "," in addr else ""
449450
node_dict = {
450451
"node_id": node_id,
452+
"hostname": hostname,
451453
"flags": flags,
452454
"master_id": master_id,
453455
"last_ping_sent": ping,
@@ -460,7 +462,7 @@ def _parse_node_line(line):
460462
if len(line_items) >= 9:
461463
slots, migrations = _parse_slots(line_items[8:])
462464
node_dict["slots"], node_dict["migrations"] = slots, migrations
463-
return addr, node_dict
465+
return ip, node_dict
464466

465467

466468
def _parse_slots(slot_ranges):

redis/asyncio/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,12 @@ async def aclose(self, close_connection_pool: Optional[bool] = None) -> None:
579579
"""
580580
Closes Redis client connection
581581
582-
:param close_connection_pool: decides whether to close the connection pool used
583-
by this Redis client, overriding Redis.auto_close_connection_pool. By default,
584-
let Redis.auto_close_connection_pool decide whether to close the connection
585-
pool.
582+
Args:
583+
close_connection_pool:
584+
decides whether to close the connection pool used by this Redis client,
585+
overriding Redis.auto_close_connection_pool.
586+
By default, let Redis.auto_close_connection_pool decide
587+
whether to close the connection pool.
586588
"""
587589
conn = self.connection
588590
if conn:

redis/commands/core.py

Lines changed: 36 additions & 23 deletions
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.
@@ -5480,7 +5483,7 @@ def __call__(
54805483
self,
54815484
keys: Union[Sequence[KeyT], None] = None,
54825485
args: Union[Iterable[EncodableT], None] = None,
5483-
client: Union["Redis", None] = None,
5486+
client: Union["redis.client.Redis", None] = None,
54845487
):
54855488
"""Execute the script, passing any required ``args``"""
54865489
keys = keys or []
@@ -5527,7 +5530,11 @@ class AsyncScript:
55275530
An executable Lua script object returned by ``register_script``
55285531
"""
55295532

5530-
def __init__(self, registered_client: "AsyncRedis", script: ScriptTextT):
5533+
def __init__(
5534+
self,
5535+
registered_client: "redis.asyncio.client.Redis",
5536+
script: ScriptTextT,
5537+
):
55315538
self.registered_client = registered_client
55325539
self.script = script
55335540
# Precalculate and store the SHA1 hex digest of the script.
@@ -5547,7 +5554,7 @@ async def __call__(
55475554
self,
55485555
keys: Union[Sequence[KeyT], None] = None,
55495556
args: Union[Iterable[EncodableT], None] = None,
5550-
client: Union["AsyncRedis", None] = None,
5557+
client: Union["redis.asyncio.client.Redis", None] = None,
55515558
):
55525559
"""Execute the script, passing any required ``args``"""
55535560
keys = keys or []
@@ -5772,7 +5779,7 @@ def script_load(self, script: ScriptTextT) -> ResponseT:
57725779
"""
57735780
return self.execute_command("SCRIPT LOAD", script)
57745781

5775-
def register_script(self: "Redis", script: ScriptTextT) -> Script:
5782+
def register_script(self: "redis.client.Redis", script: ScriptTextT) -> Script:
57765783
"""
57775784
Register a Lua ``script`` specifying the ``keys`` it will touch.
57785785
Returns a Script object that is callable and hides the complexity of
@@ -5786,7 +5793,10 @@ class AsyncScriptCommands(ScriptCommands):
57865793
async def script_debug(self, *args) -> None:
57875794
return super().script_debug()
57885795

5789-
def register_script(self: "AsyncRedis", script: ScriptTextT) -> AsyncScript:
5796+
def register_script(
5797+
self: "redis.asyncio.client.Redis",
5798+
script: ScriptTextT,
5799+
) -> AsyncScript:
57905800
"""
57915801
Register a Lua ``script`` specifying the ``keys`` it will touch.
57925802
Returns a Script object that is callable and hides the complexity of
@@ -6373,9 +6383,12 @@ def function_list(
63736383
) -> Union[Awaitable[List], List]:
63746384
"""
63756385
Return information about the functions and libraries.
6376-
:param library: pecify a pattern for matching library names
6377-
:param withcode: cause the server to include the libraries source
6378-
implementation in the reply
6386+
6387+
Args:
6388+
6389+
library: specify a pattern for matching library names
6390+
withcode: cause the server to include the libraries source implementation
6391+
in the reply
63796392
"""
63806393
args = ["LIBRARYNAME", library]
63816394
if withcode:

redis/commands/timeseries/commands.py

Lines changed: 55 additions & 55 deletions
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

tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def devenv(c):
1414
"""Brings up the test environment, by wrapping docker compose."""
1515
clean(c)
16-
cmd = "docker-compose --profile all up -d --build"
16+
cmd = "docker compose --profile all up -d --build"
1717
run(cmd)
1818

1919

@@ -85,7 +85,7 @@ def clean(c):
8585
shutil.rmtree("build")
8686
if os.path.isdir("dist"):
8787
shutil.rmtree("dist")
88-
run("docker-compose --profile all rm -s -f")
88+
run("docker compose --profile all rm -s -f")
8989

9090

9191
@task

0 commit comments

Comments
 (0)