Skip to content

Commit 8b0f317

Browse files
fix: change local variables from Sequence[str] to list[str] where .append() is used
Fixed type annotations for local variables that are initialized as empty lists and built up using .append(). These variables should be typed as list[str] rather than Sequence[str] since Sequence is immutable and doesn't support .append(). Changes: - elasticsearch/store.py: all_keys in _get_collection_keys - redis/store.py: keys in _get_collection_keys - limit_size/wrapper.py: filtered_keys in put_many - passthrough_cache/wrapper.py: entries_to_cache_keys in get_many and ttl_many Note: Sync library regeneration will be done in CI which has Python 3.10. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: William Easton <strawgate@users.noreply.github.com>
1 parent 9edfb0d commit 8b0f317

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

key-value/key-value-aio/src/key_value/aio/stores/elasticsearch/store.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from typing import TYPE_CHECKING, Any, overload
22

3-
if TYPE_CHECKING:
4-
from collections.abc import Sequence
5-
63
from key_value.shared.utils.compound import compound_key
74
from key_value.shared.utils.managed_entry import ManagedEntry, load_from_json
85
from key_value.shared.utils.sanitize import (
@@ -256,7 +253,7 @@ async def _get_collection_keys(self, *, collection: str, limit: int | None = Non
256253
if not (hits := get_hits_from_response(response=result)):
257254
return []
258255

259-
all_keys: Sequence[str] = []
256+
all_keys: list[str] = []
260257

261258
for hit in hits:
262259
if not (key := get_first_value_from_field_in_hit(hit=hit, field="key", value_type=str)):

key-value/key-value-aio/src/key_value/aio/stores/redis/store.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from typing import TYPE_CHECKING, Any, overload
1+
from typing import Any, overload
22
from urllib.parse import urlparse
33

4-
if TYPE_CHECKING:
5-
from collections.abc import Sequence
6-
74
from key_value.shared.type_checking.bear_spray import bear_spray
85
from key_value.shared.utils.compound import compound_key, get_keys_from_compound_keys
96
from key_value.shared.utils.managed_entry import ManagedEntry
@@ -131,7 +128,7 @@ async def _get_collection_keys(self, *, collection: str, limit: int | None = Non
131128

132129
# redis.asyncio scan returns tuple(cursor, keys)
133130
_cursor: int
134-
keys: Sequence[str]
131+
keys: list[str]
135132
_cursor, keys = await self._client.scan(cursor=0, match=pattern, count=limit) # pyright: ignore[reportUnknownMemberType, reportAny]
136133

137134
return get_keys_from_compound_keys(compound_keys=keys, collection=collection)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def put_many(
9393
collection: str | None = None,
9494
ttl: Sequence[SupportsFloat | None] | None = None,
9595
) -> None:
96-
filtered_keys: Sequence[str] = []
96+
filtered_keys: list[str] = []
9797
filtered_values: list[Mapping[str, Any]] = []
9898
filtered_ttls: list[SupportsFloat | None] | None = None
9999

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async def get_many(self, keys: Sequence[str], *, collection: str | None = None)
7575
)
7676

7777
entries_to_cache: list[dict[str, Any]] = []
78-
entries_to_cache_keys: Sequence[str] = []
78+
entries_to_cache_keys: list[str] = []
7979
entries_to_cache_ttls: list[float | None] = []
8080

8181
for i, key in enumerate(uncached_keys):
@@ -132,7 +132,7 @@ async def ttl_many(self, keys: Sequence[str], *, collection: str | None = None)
132132
)
133133

134134
entries_to_cache: list[dict[str, Any]] = []
135-
entries_to_cache_keys: Sequence[str] = []
135+
entries_to_cache_keys: list[str] = []
136136
entries_to_cache_ttls: list[float | None] = []
137137

138138
for i, key in enumerate(uncached_keys):

0 commit comments

Comments
 (0)