Skip to content

Commit 3110e57

Browse files
authored
Merge branch 'master' into issue/3139
2 parents e322a69 + 5977e38 commit 3110e57

File tree

8 files changed

+42
-37
lines changed

8 files changed

+42
-37
lines changed

.github/actions/run-tests/action.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ runs:
4646
CLIENT_LIBS_TEST_IMAGE_TAG: ${{ inputs.redis-version }}
4747
run: |
4848
set -e
49-
49+
5050
echo "::group::Installing dependencies"
5151
pip install -r dev_requirements.txt
5252
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
@@ -57,80 +57,79 @@ runs:
5757
pip install -e ./hiredis-py
5858
else
5959
pip install "hiredis${{inputs.hiredis-version}}"
60-
fi
60+
fi
6161
echo "PARSER_BACKEND=$(echo "${{inputs.parser-backend}}_${{inputs.hiredis-version}}" | sed 's/[^a-zA-Z0-9]/_/g')" >> $GITHUB_ENV
6262
else
6363
echo "PARSER_BACKEND=${{inputs.parser-backend}}" >> $GITHUB_ENV
6464
fi
6565
echo "::endgroup::"
66-
66+
6767
echo "::group::Starting Redis servers"
6868
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
6969
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
70-
70+
7171
if (( redis_major_version < 8 )); then
7272
echo "Using redis-stack for module tests"
73-
74-
# Mapping of redis version to stack version
73+
74+
# Mapping of redis version to stack version
7575
declare -A redis_stack_version_mapping=(
7676
["7.4.2"]="rs-7.4.0-v2"
7777
["7.2.7"]="rs-7.2.0-v14"
78-
["6.2.17"]="rs-6.2.6-v18"
7978
)
80-
79+
8180
if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then
8281
export CLIENT_LIBS_TEST_STACK_IMAGE_TAG=${redis_stack_version_mapping[$REDIS_VERSION]}
8382
echo "REDIS_MOD_URL=redis://127.0.0.1:6479/0" >> $GITHUB_ENV
8483
else
8584
echo "Version not found in the mapping."
8685
exit 1
8786
fi
88-
87+
8988
if (( redis_major_version < 7 )); then
9089
export REDIS_STACK_EXTRA_ARGS="--tls-auth-clients optional --save ''"
91-
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
90+
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
9291
fi
93-
92+
9493
invoke devenv --endpoints=all-stack
9594
else
9695
echo "Using redis CE for module tests"
9796
echo "REDIS_MOD_URL=redis://127.0.0.1:6379" >> $GITHUB_ENV
9897
invoke devenv --endpoints all
99-
fi
100-
98+
fi
99+
101100
sleep 10 # time to settle
102101
echo "::endgroup::"
103102
shell: bash
104103

105104
- name: Run tests
106105
run: |
107106
set -e
108-
107+
109108
run_tests() {
110109
local protocol=$1
111110
local eventloop=""
112-
111+
113112
if [ "${{inputs.event-loop}}" == "uvloop" ]; then
114113
eventloop="--uvloop"
115114
fi
116-
115+
117116
echo "::group::RESP${protocol} standalone tests"
118117
echo "REDIS_MOD_URL=${REDIS_MOD_URL}"
119-
118+
120119
if (( $REDIS_MAJOR_VERSION < 7 )) && [ "$protocol" == "3" ]; then
121120
echo "Skipping module tests: Modules doesn't support RESP3 for Redis versions < 7"
122121
invoke standalone-tests --redis-mod-url=${REDIS_MOD_URL} $eventloop --protocol="${protocol}" --extra-markers="not redismod and not cp_integration"
123-
else
122+
else
124123
invoke standalone-tests --redis-mod-url=${REDIS_MOD_URL} $eventloop --protocol="${protocol}"
125124
fi
126-
125+
127126
echo "::endgroup::"
128-
127+
129128
echo "::group::RESP${protocol} cluster tests"
130129
invoke cluster-tests $eventloop --protocol=${protocol}
131-
echo "::endgroup::"
130+
echo "::endgroup::"
132131
}
133-
132+
134133
run_tests 2 "${{inputs.event-loop}}"
135134
run_tests 3 "${{inputs.event-loop}}"
136135
shell: bash

.github/workflows/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
max-parallel: 15
7575
fail-fast: false
7676
matrix:
77-
redis-version: ['8.0.1-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.7', '6.2.17']
77+
redis-version: ['8.0.1-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.7']
7878
python-version: ['3.9', '3.13']
7979
parser-backend: ['plain']
8080
event-loop: ['asyncio']

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.48.0
11+
uses: rojopolis/spellcheck-github-actions@0.49.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

redis/asyncio/connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,11 @@ def __init__(
11121112
self._event_dispatcher = EventDispatcher()
11131113

11141114
def __repr__(self):
1115+
conn_kwargs = ",".join([f"{k}={v}" for k, v in self.connection_kwargs.items()])
11151116
return (
11161117
f"<{self.__class__.__module__}.{self.__class__.__name__}"
1117-
f"({self.connection_class(**self.connection_kwargs)!r})>"
1118+
f"(<{self.connection_class.__module__}.{self.connection_class.__name__}"
1119+
f"({conn_kwargs})>)>"
11181120
)
11191121

11201122
def reset(self):

redis/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def pipeline(self, transaction=True, shard_hint=None) -> "Pipeline":
450450

451451
def transaction(
452452
self, func: Callable[["Pipeline"], None], *watches, **kwargs
453-
) -> None:
453+
) -> Union[List[Any], Any, None]:
454454
"""
455455
Convenience method for executing the callable `func` as a transaction
456456
while watching all keys specified in `watches`. The 'func' callable

redis/connection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,10 +1432,12 @@ def __init__(
14321432

14331433
self.reset()
14341434

1435-
def __repr__(self) -> (str, str):
1435+
def __repr__(self) -> str:
1436+
conn_kwargs = ",".join([f"{k}={v}" for k, v in self.connection_kwargs.items()])
14361437
return (
1437-
f"<{type(self).__module__}.{type(self).__name__}"
1438-
f"({repr(self.connection_class(**self.connection_kwargs))})>"
1438+
f"<{self.__class__.__module__}.{self.__class__.__name__}"
1439+
f"(<{self.connection_class.__module__}.{self.connection_class.__name__}"
1440+
f"({conn_kwargs})>)>"
14391441
)
14401442

14411443
def get_protocol(self):

tests/test_asyncio/test_connection_pool.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,14 @@ def test_repr_contains_db_info_tcp(self):
294294
pool = redis.ConnectionPool(
295295
host="localhost", port=6379, client_name="test-client"
296296
)
297-
expected = "host=localhost,port=6379,db=0,client_name=test-client"
297+
expected = "host=localhost,port=6379,client_name=test-client"
298298
assert expected in repr(pool)
299299

300300
def test_repr_contains_db_info_unix(self):
301301
pool = redis.ConnectionPool(
302302
connection_class=redis.UnixDomainSocketConnection,
303303
path="abc",
304+
db=0,
304305
client_name="test-client",
305306
)
306307
expected = "path=abc,db=0,client_name=test-client"
@@ -651,15 +652,15 @@ async def test_oom_error(self, r):
651652
await r.execute_command("DEBUG", "ERROR", "OOM blah blah")
652653

653654
def test_connect_from_url_tcp(self):
654-
connection = redis.Redis.from_url("redis://localhost")
655+
connection = redis.Redis.from_url("redis://localhost:6379?db=0")
655656
pool = connection.connection_pool
656657

657658
assert re.match(
658659
r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >", repr(pool), re.VERBOSE
659660
).groups() == (
660661
"ConnectionPool",
661662
"Connection",
662-
"host=localhost,port=6379,db=0",
663+
"db=0,host=localhost,port=6379",
663664
)
664665

665666
def test_connect_from_url_unix(self):
@@ -671,7 +672,7 @@ def test_connect_from_url_unix(self):
671672
).groups() == (
672673
"ConnectionPool",
673674
"UnixDomainSocketConnection",
674-
"path=/path/to/socket,db=0",
675+
"path=/path/to/socket",
675676
)
676677

677678
@skip_if_redis_enterprise()

tests/test_connection_pool.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ def test_repr_contains_db_info_tcp(self):
205205
pool = redis.ConnectionPool(
206206
host="localhost", port=6379, client_name="test-client"
207207
)
208-
expected = "host=localhost,port=6379,db=0,client_name=test-client"
208+
expected = "host=localhost,port=6379,client_name=test-client"
209209
assert expected in repr(pool)
210210

211211
def test_repr_contains_db_info_unix(self):
212212
pool = redis.ConnectionPool(
213213
connection_class=redis.UnixDomainSocketConnection,
214214
path="abc",
215+
db=0,
215216
client_name="test-client",
216217
)
217218
expected = "path=abc,db=0,client_name=test-client"
@@ -598,15 +599,15 @@ def test_oom_error(self, r):
598599
r.execute_command("DEBUG", "ERROR", "OOM blah blah")
599600

600601
def test_connect_from_url_tcp(self):
601-
connection = redis.Redis.from_url("redis://localhost")
602+
connection = redis.Redis.from_url("redis://localhost:6379?db=0")
602603
pool = connection.connection_pool
603604

604605
assert re.match(
605606
r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >", repr(pool), re.VERBOSE
606607
).groups() == (
607608
"ConnectionPool",
608609
"Connection",
609-
"host=localhost,port=6379,db=0",
610+
"db=0,host=localhost,port=6379",
610611
)
611612

612613
def test_connect_from_url_unix(self):
@@ -618,7 +619,7 @@ def test_connect_from_url_unix(self):
618619
).groups() == (
619620
"ConnectionPool",
620621
"UnixDomainSocketConnection",
621-
"path=/path/to/socket,db=0",
622+
"path=/path/to/socket",
622623
)
623624

624625
@skip_if_redis_enterprise()

0 commit comments

Comments
 (0)