Update parts.py

Fixed bug in paginate function. The previous code was not working.
This commit is contained in:
JAKHONGIR ISMOILOV 2022-09-23 22:21:09 +05:00 committed by GitHub
parent 95529aef18
commit 8590677e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,17 +44,15 @@ def safe_split_text(text: str, length: int = MAX_MESSAGE_LENGTH, split_separator
return parts
def paginate(data: typing.Iterable, page: int = 0, limit: int = 10) -> typing.Iterable:
def paginate(data: typing.Iterable, limit: int = 10) -> typing.Iterable:
"""
Slice data over pages
:param data: any iterable object
:type data: :obj:`typing.Iterable`
:param page: number of page
:type page: :obj:`int`
:param limit: items per page
:type limit: :obj:`int`
:return: sliced object
:rtype: :obj:`typing.Iterable`
"""
return data[page * limit:page * limit + limit]
return [data[x:x + limit] for x in range(0, len(data), 4)]