Skip to content

Commit ec31fa1

Browse files
committed
Fix ItemList typing
1 parent 1a3df22 commit ec31fa1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/guidellm/preprocess/item.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Sequence
2-
from typing import Generic, Optional, TypeVar, Union
2+
from typing import Generic, Optional, TypeVar
33

44
from pydantic import Field
55

@@ -10,7 +10,8 @@
1010

1111
class Item(StandardBaseModel, Generic[PromptT]):
1212
"""
13-
Represents a single item in a dataset, containing a prompt and its associated metadata.
13+
Represents a single item in a dataset,
14+
containing a prompt and its associated metadata.
1415
"""
1516

1617
value: PromptT = Field(
@@ -33,11 +34,13 @@ class ItemList(Sequence[Item[PromptT]]):
3334
Represents a list of items, each containing a prompt and its metadata.
3435
"""
3536

37+
shared_prefix: Optional[PromptT]
38+
3639
def __init__(self, *items: Item[PromptT], shared_prefix: Optional[PromptT] = None):
37-
self.shared_prefix: Optional[PromptT] = shared_prefix
38-
self._items: list[Item[PromptT]] = list(items)
40+
self.shared_prefix = shared_prefix
41+
self._items = list(items)
3942

40-
def __getitem__(self, key) -> Union[Item[PromptT], Sequence[Item[PromptT]]]:
43+
def __getitem__(self, key):
4144
return self._items[key]
4245

4346
def __len__(self) -> int:

0 commit comments

Comments
 (0)