Skip to content

Undocumented Paginator error #2992

@matejpopda

Description

@matejpopda

Initializing Paginator with show_menu=False throws an undocumented error when all the pages are PageGroup objects

Minimal reproducible example:

from discord.ext.pages import Paginator, PageGroup
Paginator(pages=[PageGroup(["a","b"], "label")])

Resulting error:

  File "c:\temp\bot\src\help.py", line 49, in get_help_paginator
     Paginator(pages=[PageGroup(["a","b"], "label")])
  File "C:\temp\bot\.venv\Lib\site-packages\discord\ext\pages\pagination.py", line 412, in __init__
    if all(isinstance(pg, PageGroup) for pg in pages):
                                               ^^^^^
TypeError: 'NoneType' object is not iterable

Caused by this line

if all(isinstance(pg, PageGroup) for pg in pages):
self.page_groups = self.pages if show_menu else None
if sum(pg.default is True for pg in self.page_groups) > 1:

If show_menu is false (dafault argument for the Paginator), line 422 tries to iterate over the None assigned in line 421.

Expected behavior should be following, based on the Paginator docstring.
If a list of :class:`PageGroup` objects is provided and `show_menu` is ``False``, only the first page group will be displayed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions