Skip to content

Commit b52d3bb

Browse files
committed
fix(QueryList): Make truly generic
1 parent 6f898b6 commit b52d3bb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libvcs/_internal/query_list.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import re
88
import traceback
99
import typing as t
10-
from collections.abc import Mapping, Sequence
10+
from collections.abc import Iterable, Mapping, Sequence
1111

12-
T = t.TypeVar("T", t.Any, t.Any)
12+
T = t.TypeVar("T")
1313
no_arg = object()
1414

1515

@@ -312,7 +312,7 @@ def __init__(self, op: str, *args: object):
312312
return super().__init__(f"{op} not in LOOKUP_NAME_MAP")
313313

314314

315-
class QueryList(list[T]):
315+
class QueryList(t.Generic[T], list[T]):
316316
"""Filter list of object/dictionaries. For small, local datasets.
317317
318318
*Experimental, unstable*.
@@ -464,6 +464,9 @@ class QueryList(list[T]):
464464
data: Sequence[T]
465465
pk_key: t.Optional[str]
466466

467+
def __init__(self, items: t.Optional["Iterable[T]"] = None) -> None:
468+
super().__init__(items if items is not None else [])
469+
467470
def items(self) -> list[T]:
468471
if self.pk_key is None:
469472
raise PKRequiredException()

0 commit comments

Comments
 (0)