Skip to content

Commit 2d648a4

Browse files
author
Mikhail Koviazin
authored
Merge pull request #172 from valkey-io/mkmkme/fix-isort
Fix updated linters errors
2 parents 457be2d + 05e1f31 commit 2d648a4

File tree

8 files changed

+46
-28
lines changed

8 files changed

+46
-28
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def skip_ifmodversion_lt(min_version: str, module_name: str):
234234
if module_name == j.get("name"):
235235
version = j.get("ver")
236236
mv = int(
237-
"".join(["%02d" % int(segment) for segment in min_version.split(".")])
237+
"".join([f"{int(segment):02}" for segment in min_version.split(".")])
238238
)
239239
check = version < mv
240240
return pytest.mark.skipif(check, reason="Valkey module version")

tests/test_asyncio/test_cluster.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import binascii
33
import datetime
4+
import math
45
import ssl
56
import warnings
67
from typing import Any, Awaitable, Callable, Dict, List, Optional, Type, Union
@@ -1556,23 +1557,23 @@ async def test_cluster_bitop_not_empty_string(self, r: ValkeyCluster) -> None:
15561557

15571558
@skip_if_server_version_lt("2.6.0")
15581559
async def test_cluster_bitop_not(self, r: ValkeyCluster) -> None:
1559-
test_str = b"\xAA\x00\xFF\x55"
1560+
test_str = b"\xaa\x00\xff\x55"
15601561
correct = ~0xAA00FF55 & 0xFFFFFFFF
15611562
await r.set("{foo}a", test_str)
15621563
await r.bitop("not", "{foo}r", "{foo}a")
15631564
assert int(binascii.hexlify(await r.get("{foo}r")), 16) == correct
15641565

15651566
@skip_if_server_version_lt("2.6.0")
15661567
async def test_cluster_bitop_not_in_place(self, r: ValkeyCluster) -> None:
1567-
test_str = b"\xAA\x00\xFF\x55"
1568+
test_str = b"\xaa\x00\xff\x55"
15681569
correct = ~0xAA00FF55 & 0xFFFFFFFF
15691570
await r.set("{foo}a", test_str)
15701571
await r.bitop("not", "{foo}a", "{foo}a")
15711572
assert int(binascii.hexlify(await r.get("{foo}a")), 16) == correct
15721573

15731574
@skip_if_server_version_lt("2.6.0")
15741575
async def test_cluster_bitop_single_string(self, r: ValkeyCluster) -> None:
1575-
test_str = b"\x01\x02\xFF"
1576+
test_str = b"\x01\x02\xff"
15761577
await r.set("{foo}a", test_str)
15771578
await r.bitop("and", "{foo}res1", "{foo}a")
15781579
await r.bitop("or", "{foo}res2", "{foo}a")
@@ -1583,8 +1584,8 @@ async def test_cluster_bitop_single_string(self, r: ValkeyCluster) -> None:
15831584

15841585
@skip_if_server_version_lt("2.6.0")
15851586
async def test_cluster_bitop_string_operands(self, r: ValkeyCluster) -> None:
1586-
await r.set("{foo}a", b"\x01\x02\xFF\xFF")
1587-
await r.set("{foo}b", b"\x01\x02\xFF")
1587+
await r.set("{foo}a", b"\x01\x02\xff\xff")
1588+
await r.set("{foo}b", b"\x01\x02\xff")
15881589
await r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
15891590
await r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
15901591
await r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")
@@ -2158,7 +2159,9 @@ async def test_geosearchstore_dist(self, r: ValkeyCluster) -> None:
21582159
storedist=True,
21592160
)
21602161
# instead of save the geo score, the distance is saved.
2161-
assert await r.zscore("{foo}places_barcelona", "place1") == 88.05060698409301
2162+
E = 1e-9
2163+
res = await r.zscore("{foo}places_barcelona", "place1")
2164+
assert math.fabs(res - 88.05060698409301) < E
21622165

21632166
@skip_if_server_version_lt("3.2.0")
21642167
async def test_cluster_georadius_store(self, r: ValkeyCluster) -> None:
@@ -2188,7 +2191,9 @@ async def test_cluster_georadius_store_dist(self, r: ValkeyCluster) -> None:
21882191
"{foo}barcelona", 2.191, 41.433, 1000, store_dist="{foo}places_barcelona"
21892192
)
21902193
# instead of save the geo score, the distance is saved.
2191-
assert await r.zscore("{foo}places_barcelona", "place1") == 88.05060698409301
2194+
E = 1e-9
2195+
res = await r.zscore("{foo}places_barcelona", "place1")
2196+
assert math.fabs(res - 88.05060698409301) < E
21922197

21932198
async def test_cluster_dbsize(self, r: ValkeyCluster) -> None:
21942199
d = {"a": b"1", "b": b"2", "c": b"3", "d": b"4"}

tests/test_asyncio/test_commands.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ async def test_bitop_not_empty_string(self, r: valkey.Valkey):
639639
@skip_if_server_version_lt("2.6.0")
640640
@pytest.mark.onlynoncluster
641641
async def test_bitop_not(self, r: valkey.Valkey):
642-
test_str = b"\xAA\x00\xFF\x55"
642+
test_str = b"\xaa\x00\xff\x55"
643643
correct = ~0xAA00FF55 & 0xFFFFFFFF
644644
await r.set("a", test_str)
645645
await r.bitop("not", "r", "a")
@@ -648,7 +648,7 @@ async def test_bitop_not(self, r: valkey.Valkey):
648648
@skip_if_server_version_lt("2.6.0")
649649
@pytest.mark.onlynoncluster
650650
async def test_bitop_not_in_place(self, r: valkey.Valkey):
651-
test_str = b"\xAA\x00\xFF\x55"
651+
test_str = b"\xaa\x00\xff\x55"
652652
correct = ~0xAA00FF55 & 0xFFFFFFFF
653653
await r.set("a", test_str)
654654
await r.bitop("not", "a", "a")
@@ -657,7 +657,7 @@ async def test_bitop_not_in_place(self, r: valkey.Valkey):
657657
@skip_if_server_version_lt("2.6.0")
658658
@pytest.mark.onlynoncluster
659659
async def test_bitop_single_string(self, r: valkey.Valkey):
660-
test_str = b"\x01\x02\xFF"
660+
test_str = b"\x01\x02\xff"
661661
await r.set("a", test_str)
662662
await r.bitop("and", "res1", "a")
663663
await r.bitop("or", "res2", "a")
@@ -669,8 +669,8 @@ async def test_bitop_single_string(self, r: valkey.Valkey):
669669
@skip_if_server_version_lt("2.6.0")
670670
@pytest.mark.onlynoncluster
671671
async def test_bitop_string_operands(self, r: valkey.Valkey):
672-
await r.set("a", b"\x01\x02\xFF\xFF")
673-
await r.set("b", b"\x01\x02\xFF")
672+
await r.set("a", b"\x01\x02\xff\xff")
673+
await r.set("b", b"\x01\x02\xff")
674674
await r.bitop("and", "res1", "a", "b")
675675
await r.bitop("or", "res2", "a", "b")
676676
await r.bitop("xor", "res3", "a", "b")

tests/test_cluster.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import binascii
22
import datetime
3+
import math
34
import select
45
import socket
56
import socketserver
@@ -1663,23 +1664,23 @@ def test_cluster_bitop_not_empty_string(self, r):
16631664

16641665
@skip_if_server_version_lt("2.6.0")
16651666
def test_cluster_bitop_not(self, r):
1666-
test_str = b"\xAA\x00\xFF\x55"
1667+
test_str = b"\xaa\x00\xff\x55"
16671668
correct = ~0xAA00FF55 & 0xFFFFFFFF
16681669
r["{foo}a"] = test_str
16691670
r.bitop("not", "{foo}r", "{foo}a")
16701671
assert int(binascii.hexlify(r["{foo}r"]), 16) == correct
16711672

16721673
@skip_if_server_version_lt("2.6.0")
16731674
def test_cluster_bitop_not_in_place(self, r):
1674-
test_str = b"\xAA\x00\xFF\x55"
1675+
test_str = b"\xaa\x00\xff\x55"
16751676
correct = ~0xAA00FF55 & 0xFFFFFFFF
16761677
r["{foo}a"] = test_str
16771678
r.bitop("not", "{foo}a", "{foo}a")
16781679
assert int(binascii.hexlify(r["{foo}a"]), 16) == correct
16791680

16801681
@skip_if_server_version_lt("2.6.0")
16811682
def test_cluster_bitop_single_string(self, r):
1682-
test_str = b"\x01\x02\xFF"
1683+
test_str = b"\x01\x02\xff"
16831684
r["{foo}a"] = test_str
16841685
r.bitop("and", "{foo}res1", "{foo}a")
16851686
r.bitop("or", "{foo}res2", "{foo}a")
@@ -1690,8 +1691,8 @@ def test_cluster_bitop_single_string(self, r):
16901691

16911692
@skip_if_server_version_lt("2.6.0")
16921693
def test_cluster_bitop_string_operands(self, r):
1693-
r["{foo}a"] = b"\x01\x02\xFF\xFF"
1694-
r["{foo}b"] = b"\x01\x02\xFF"
1694+
r["{foo}a"] = b"\x01\x02\xff\xff"
1695+
r["{foo}b"] = b"\x01\x02\xff"
16951696
r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
16961697
r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
16971698
r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")
@@ -2247,7 +2248,11 @@ def test_geosearchstore_dist(self, r):
22472248
storedist=True,
22482249
)
22492250
# instead of save the geo score, the distance is saved.
2250-
assert r.zscore("{foo}places_barcelona", "place1") == 88.05060698409301
2251+
E = 1e-9
2252+
assert (
2253+
math.fabs(r.zscore("{foo}places_barcelona", "place1") - 88.05060698409301)
2254+
< E
2255+
)
22512256

22522257
@skip_if_server_version_lt("3.2.0")
22532258
def test_cluster_georadius_store(self, r):
@@ -2277,7 +2282,11 @@ def test_cluster_georadius_store_dist(self, r):
22772282
"{foo}barcelona", 2.191, 41.433, 1000, store_dist="{foo}places_barcelona"
22782283
)
22792284
# instead of save the geo score, the distance is saved.
2280-
assert r.zscore("{foo}places_barcelona", "place1") == 88.05060698409301
2285+
E = 1e-9
2286+
assert (
2287+
math.fabs(r.zscore("{foo}places_barcelona", "place1") - 88.05060698409301)
2288+
< E
2289+
)
22812290

22822291
def test_cluster_dbsize(self, r):
22832292
d = {"a": b"1", "b": b"2", "c": b"3", "d": b"4"}

tests/test_commands.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ def test_bitop_not_empty_string(self, r):
10151015
@pytest.mark.onlynoncluster
10161016
@skip_if_server_version_lt("2.6.0")
10171017
def test_bitop_not(self, r):
1018-
test_str = b"\xAA\x00\xFF\x55"
1018+
test_str = b"\xaa\x00\xff\x55"
10191019
correct = ~0xAA00FF55 & 0xFFFFFFFF
10201020
r["a"] = test_str
10211021
r.bitop("not", "r", "a")
@@ -1024,7 +1024,7 @@ def test_bitop_not(self, r):
10241024
@pytest.mark.onlynoncluster
10251025
@skip_if_server_version_lt("2.6.0")
10261026
def test_bitop_not_in_place(self, r):
1027-
test_str = b"\xAA\x00\xFF\x55"
1027+
test_str = b"\xaa\x00\xff\x55"
10281028
correct = ~0xAA00FF55 & 0xFFFFFFFF
10291029
r["a"] = test_str
10301030
r.bitop("not", "a", "a")
@@ -1033,7 +1033,7 @@ def test_bitop_not_in_place(self, r):
10331033
@pytest.mark.onlynoncluster
10341034
@skip_if_server_version_lt("2.6.0")
10351035
def test_bitop_single_string(self, r):
1036-
test_str = b"\x01\x02\xFF"
1036+
test_str = b"\x01\x02\xff"
10371037
r["a"] = test_str
10381038
r.bitop("and", "res1", "a")
10391039
r.bitop("or", "res2", "a")
@@ -1045,8 +1045,8 @@ def test_bitop_single_string(self, r):
10451045
@pytest.mark.onlynoncluster
10461046
@skip_if_server_version_lt("2.6.0")
10471047
def test_bitop_string_operands(self, r):
1048-
r["a"] = b"\x01\x02\xFF\xFF"
1049-
r["b"] = b"\x01\x02\xFF"
1048+
r["a"] = b"\x01\x02\xff\xff"
1049+
r["b"] = b"\x01\x02\xff"
10501050
r.bitop("and", "res1", "a", "b")
10511051
r.bitop("or", "res2", "a", "b")
10521052
r.bitop("xor", "res3", "a", "b")

valkey/_parsers/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ def parse_stralgo(response, **options):
425425
if options.get("idx", False):
426426
if options.get("withmatchlen", False):
427427
matches = [
428-
[(int(match[-1]))] + list(map(tuple, match[:-1]))
429-
for match in response[1]
428+
[int(match[-1])] + list(map(tuple, match[:-1])) for match in response[1]
430429
]
431430
else:
432431
matches = [list(map(tuple, match)) for match in response[1]]

valkey/_parsers/url_parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from typing import Callable, Mapping, Optional
44
from urllib.parse import ParseResult, parse_qs, unquote, urlparse
55

6-
from valkey.asyncio.connection import ConnectKwargs
6+
from valkey.asyncio.connection import (
7+
ConnectKwargs,
8+
)
79
from valkey.asyncio.connection import SSLConnection as SSLConnectionAsync
810
from valkey.asyncio.connection import (
911
UnixDomainSocketConnection as UnixDomainSocketConnectionAsync,

valkey/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class ModuleError(ResponseError):
7979

8080
class LockError(ValkeyError, ValueError):
8181
"Errors acquiring or releasing a lock"
82+
8283
# NOTE: For backwards compatibility, this class derives from ValueError.
8384
# This was originally chosen to behave like threading.Lock.
8485

@@ -89,11 +90,13 @@ def __init__(self, message=None, lock_name=None):
8990

9091
class LockNotOwnedError(LockError):
9192
"Error trying to extend or release a lock that is (no longer) owned"
93+
9294
pass
9395

9496

9597
class ChildDeadlockedError(Exception):
9698
"Error indicating that a child process is deadlocked after a fork()"
99+
97100
pass
98101

99102

0 commit comments

Comments
 (0)