Skip to content

strands.types.collections

Generic collection types for the Strands SDK.

T = TypeVar('T') module-attribute

PaginatedList

Bases: list, Generic[T]

A generic list-like object that includes a pagination token.

This maintains backwards compatibility by inheriting from list, so existing code that expects List[T] will continue to work.

Source code in strands/types/collections.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class PaginatedList(list, Generic[T]):
    """A generic list-like object that includes a pagination token.

    This maintains backwards compatibility by inheriting from list,
    so existing code that expects List[T] will continue to work.
    """

    def __init__(self, data: List[T], token: Optional[str] = None):
        """Initialize a PaginatedList with data and an optional pagination token.

        Args:
            data: The list of items to store.
            token: Optional pagination token for retrieving additional items.
        """
        super().__init__(data)
        self.pagination_token = token

__init__(data, token=None)

Initialize a PaginatedList with data and an optional pagination token.

Parameters:

Name Type Description Default
data List[T]

The list of items to store.

required
token Optional[str]

Optional pagination token for retrieving additional items.

None
Source code in strands/types/collections.py
15
16
17
18
19
20
21
22
23
def __init__(self, data: List[T], token: Optional[str] = None):
    """Initialize a PaginatedList with data and an optional pagination token.

    Args:
        data: The list of items to store.
        token: Optional pagination token for retrieving additional items.
    """
    super().__init__(data)
    self.pagination_token = token