Skip to content

Commit f1281f6

Browse files
fix: update routing wrapper type signatures to match protocol changes
Update RoutingWrapper to use correct type signatures: - Change keys parameters from list[str] to Sequence[str] (per #119) - Change put_many ttl from Sequence to single SupportsFloat (per #121) - Update test cases to match new put_many signature All 11 routing wrapper tests pass successfully. Co-authored-by: William Easton <strawgate@users.noreply.github.com>
1 parent d707848 commit f1281f6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

key-value/key-value-aio/src/key_value/aio/wrappers/routing/wrapper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def get(self, key: str, *, collection: str | None = None) -> dict[str, Any
7373
return await store.get(key=key, collection=collection)
7474

7575
@override
76-
async def get_many(self, keys: list[str], *, collection: str | None = None) -> list[dict[str, Any] | None]:
76+
async def get_many(self, keys: Sequence[str], *, collection: str | None = None) -> list[dict[str, Any] | None]:
7777
store = self._get_store(collection)
7878
return await store.get_many(keys=keys, collection=collection)
7979

@@ -83,7 +83,7 @@ async def ttl(self, key: str, *, collection: str | None = None) -> tuple[dict[st
8383
return await store.ttl(key=key, collection=collection)
8484

8585
@override
86-
async def ttl_many(self, keys: list[str], *, collection: str | None = None) -> list[tuple[dict[str, Any] | None, float | None]]:
86+
async def ttl_many(self, keys: Sequence[str], *, collection: str | None = None) -> list[tuple[dict[str, Any] | None, float | None]]:
8787
store = self._get_store(collection)
8888
return await store.ttl_many(keys=keys, collection=collection)
8989

@@ -95,11 +95,11 @@ async def put(self, key: str, value: Mapping[str, Any], *, collection: str | Non
9595
@override
9696
async def put_many(
9797
self,
98-
keys: list[str],
98+
keys: Sequence[str],
9999
values: Sequence[Mapping[str, Any]],
100100
*,
101101
collection: str | None = None,
102-
ttl: Sequence[SupportsFloat | None] | None = None,
102+
ttl: SupportsFloat | None = None,
103103
) -> None:
104104
store = self._get_store(collection)
105105
return await store.put_many(keys=keys, values=values, collection=collection, ttl=ttl)
@@ -110,6 +110,6 @@ async def delete(self, key: str, *, collection: str | None = None) -> bool:
110110
return await store.delete(key=key, collection=collection)
111111

112112
@override
113-
async def delete_many(self, keys: list[str], *, collection: str | None = None) -> int:
113+
async def delete_many(self, keys: Sequence[str], *, collection: str | None = None) -> int:
114114
store = self._get_store(collection)
115115
return await store.delete_many(keys=keys, collection=collection)

key-value/key-value-aio/tests/stores/wrappers/test_routing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def route(collection: str | None) -> AsyncKeyValue | None:
6363
async def test_routing_no_default_raises_error(self):
6464
"""Test that ValueError is raised when no store is found and no default."""
6565

66-
def route(collection: str | None) -> AsyncKeyValue | None: # noqa: ARG001
66+
def route(collection: str | None) -> AsyncKeyValue | None:
6767
return None
6868

6969
wrapper = RoutingWrapper(routing_function=route)
@@ -76,7 +76,7 @@ async def test_routing_get_many(self):
7676
"""Test get_many operation routes correctly."""
7777
store1 = MemoryStore()
7878

79-
def route(collection: str | None) -> AsyncKeyValue | None: # noqa: ARG001
79+
def route(collection: str | None) -> AsyncKeyValue | None:
8080
return store1
8181

8282
wrapper = RoutingWrapper(routing_function=route)
@@ -96,7 +96,7 @@ async def test_routing_delete_operations(self):
9696
"""Test delete operations route correctly."""
9797
store1 = MemoryStore()
9898

99-
def route(collection: str | None) -> AsyncKeyValue | None: # noqa: ARG001
99+
def route(collection: str | None) -> AsyncKeyValue | None:
100100
return store1
101101

102102
wrapper = RoutingWrapper(routing_function=route)
@@ -124,7 +124,7 @@ async def test_routing_ttl_operations(self):
124124
"""Test TTL operations route correctly."""
125125
store1 = MemoryStore()
126126

127-
def route(collection: str | None) -> AsyncKeyValue | None: # noqa: ARG001
127+
def route(collection: str | None) -> AsyncKeyValue | None:
128128
return store1
129129

130130
wrapper = RoutingWrapper(routing_function=route)
@@ -143,7 +143,7 @@ def route(collection: str | None) -> AsyncKeyValue | None: # noqa: ARG001
143143
keys=["key2", "key3"],
144144
values=[{"data": "v2"}, {"data": "v3"}],
145145
collection="test",
146-
ttl=[3600, 7200],
146+
ttl=3600,
147147
)
148148

149149
# TTL many

0 commit comments

Comments
 (0)