From 4d52ef7f50482cfb8714b8a4ec8cb6b89deb9abf Mon Sep 17 00:00:00 2001 From: disqualifier Date: Sun, 28 Jun 2026 15:51:40 -0400 Subject: [PATCH] fix: reject empty pages at construction (v0.1.1) empty pages gave max_pages=0; get_page(0)/start() then IndexError'd on self.pages[0]. guard in __init__ with a clear ValueError instead of a deferred crash at render. verified: ButtonPaginator([]) -> ValueError; non-empty and single-page intact. Signed-off-by: disqualifier --- pyproject.toml | 2 +- src/dpy_paginator/dpy_paginator.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b150884..b6222a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "dpy_paginator" -version = "0.1.0" +version = "0.1.1" description = "Button-navigated paginator for discord.py — config-free, injectable emojis, installable." requires-python = ">=3.10" dependencies = [ diff --git a/src/dpy_paginator/dpy_paginator.py b/src/dpy_paginator/dpy_paginator.py index 294ed0c..1335e88 100644 --- a/src/dpy_paginator/dpy_paginator.py +++ b/src/dpy_paginator/dpy_paginator.py @@ -159,6 +159,8 @@ class ButtonPaginator(Generic[PageT_co], discord.ui.View): cache_sleep: seconds to wait after priming before refreshing the view """ super().__init__(timeout=timeout) + if not pages: + raise ValueError("ButtonPaginator requires at least one page") self.author_id: Optional[int] = author_id self.delete_message_after: bool = delete_message_after self.mentions_allowed = mentions_allowed or discord.AllowedMentions.all()