Skip to content

Commit d94441e

Browse files
committed
fix(QueryList): Make truly generic
1 parent 32fff3e commit d94441e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libtmux/_internal/query_list.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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

1212
if t.TYPE_CHECKING:
1313

@@ -23,7 +23,7 @@ def __call__(
2323
...
2424

2525

26-
T = t.TypeVar("T", t.Any, t.Any)
26+
T = t.TypeVar("T")
2727

2828
no_arg = object()
2929

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

261261

262-
class QueryList(t.List[T]):
262+
class QueryList(t.Generic[T], t.List[T]):
263263
"""Filter list of object/dictionaries. For small, local datasets.
264264
265265
*Experimental, unstable*.
@@ -297,6 +297,9 @@ class QueryList(t.List[T]):
297297
data: "Sequence[T]"
298298
pk_key: t.Optional[str]
299299

300+
def __init__(self, items: t.Optional["Iterable[T]"] = None) -> None:
301+
super().__init__(items if items is not None else [])
302+
300303
def items(self) -> t.List[T]:
301304
if self.pk_key is None:
302305
raise PKRequiredException()

0 commit comments

Comments
 (0)