Skip to content

Commit 27b5b01

Browse files
authored
Merge branch 'master' into appinf
2 parents 5f939dd + e90089d commit 27b5b01

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131
- id: isort
3232
exclude: \.(po|pot|yml|yaml)$
3333
- repo: https://github.com/psf/black-pre-commit-mirror
34-
rev: 25.11.0
34+
rev: 25.12.0
3535
hooks:
3636
- id: black
3737
args: [--safe, --quiet]

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ These changes are available on the `master` branch, but have not yet been releas
2424

2525
### Fixed
2626

27+
- Fixed `TypeError` in paginator implementation when only passing `PageGroup` objects
28+
and `show_menu` is falsy.
29+
([#2993](https://github.com/Pycord-Development/pycord/pull/2993))
2730
- Fixed breaking change in `ui.Select` Generic typing by adding default values to
2831
TypeVars. ([#3002](https://github.com/Pycord-Development/pycord/pull/3002))
2932

discord/ext/pages/pagination.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,17 +418,20 @@ def __init__(
418418
self.default_page_group: int = 0
419419

420420
if all(isinstance(pg, PageGroup) for pg in pages):
421-
self.page_groups = self.pages if show_menu else None
422-
if sum(pg.default is True for pg in self.page_groups) > 1:
421+
if sum(pg.default is True for pg in pages) > 1:
423422
raise ValueError("Only one PageGroup can be set as the default.")
424-
for pg in self.page_groups:
423+
424+
default_pg_index = 0
425+
for pg in pages:
425426
if pg.default:
426-
self.default_page_group = self.page_groups.index(pg)
427+
default_pg_index = pages.index(pg)
427428
break
429+
428430
self.pages: list[Page] = self.get_page_group_content(
429-
self.page_groups[self.default_page_group]
431+
pages[default_pg_index]
430432
)
431433

434+
self.page_groups = self.pages if show_menu else None
432435
self.page_count = max(len(self.pages) - 1, 0)
433436
self.buttons = {}
434437
self.custom_buttons: list = custom_buttons
@@ -530,16 +533,20 @@ async def update(
530533
) = (pages if pages is not None else self.pages)
531534
self.show_menu = show_menu if show_menu is not None else self.show_menu
532535
if pages is not None and all(isinstance(pg, PageGroup) for pg in pages):
533-
self.page_groups = self.pages if self.show_menu else None
534-
if sum(pg.default is True for pg in self.page_groups) > 1:
536+
if sum(pg.default is True for pg in pages) > 1:
535537
raise ValueError("Only one PageGroup can be set as the default.")
536-
for pg in self.page_groups:
538+
539+
default_pg_index = 0
540+
for pg in pages:
537541
if pg.default:
538-
self.default_page_group = self.page_groups.index(pg)
542+
default_pg_index = pages.index(pg)
539543
break
544+
540545
self.pages: list[Page] = self.get_page_group_content(
541-
self.page_groups[self.default_page_group]
546+
pages[default_pg_index]
542547
)
548+
549+
self.page_groups = self.pages if show_menu else None
543550
self.page_count = max(len(self.pages) - 1, 0)
544551
self.current_page = current_page if current_page <= self.page_count else 0
545552
# Apply config changes, if specified

discord/message.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ async def save(
314314
deleted attachments if too much time has passed, and it does not work
315315
on some types of attachments.
316316
chunksize: Optional[:class:`int`]
317-
The maximum size of each chunk to process.
317+
The maximum size of each chunk to process. Must be a positive integer.
318318
319319
Returns
320320
-------
@@ -336,7 +336,7 @@ async def save(
336336
data = await self.read(use_cached=use_cached)
337337

338338
if isinstance(fp, io.BufferedIOBase):
339-
if chunksize:
339+
if chunksize is not None:
340340
written = 0
341341
async for chunk in data:
342342
written += fp.write(chunk)
@@ -347,7 +347,7 @@ async def save(
347347
return written
348348
else:
349349
with open(fp, "wb") as f:
350-
if chunksize:
350+
if chunksize is not None:
351351
written = 0
352352
async for chunk in data:
353353
written += f.write(chunk)
@@ -400,7 +400,7 @@ async def read_chunked(
400400
Parameters
401401
----------
402402
chunksize: :class:`int`
403-
The maximum size of each chunk to process.
403+
The maximum size of each chunk to process. Must be a positive integer.
404404
use_cached: :class:`bool`
405405
Whether to use :attr:`proxy_url` rather than :attr:`url` when downloading
406406
the attachment. This will allow attachments to be saved after deletion

0 commit comments

Comments
 (0)