Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a726103
fix: allow Checkbox, CheckboxGroup, FileUpload, RadioGroup
vmphase Aug 7, 2026
b704369
fix: correct set_select overload return types and option kwarg
vmphase Aug 7, 2026
8386af2
fix(select): add init overload for non-literal ComponentType
vmphase Aug 7, 2026
8b355ae
chore: update changelog
vmphase Aug 7, 2026
f8c3be0
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2026
7187afa
revert: type checks
vmphase Aug 7, 2026
068813c
chore: update changelog
vmphase Aug 7, 2026
4de8d85
Merge branch 'fix/3331' of https://github.com/Pycord-Development/pyco…
vmphase Aug 7, 2026
2247e38
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2026
c07860c
fix: make CheckBox, CheckBoxGroup, FileUpload, RadioGroup not nullable
vmphase Aug 7, 2026
3425a5b
chore: update changelog
vmphase Aug 7, 2026
9f88c3b
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2026
adfa11b
Merge branch 'master' into fix/3331
vmphase Aug 7, 2026
7d4235e
fix(checkbox): default to False
vmphase Aug 7, 2026
45baf5a
Merge branch 'master' into fix/3331
vmphase Aug 7, 2026
8be5130
refactor(ui/label): remove unused imports
vmphase Aug 7, 2026
f25f935
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2026
67482ee
chore: fix changelog
vmphase Aug 10, 2026
86bcdcb
chore: apply readme suggestion
vmphase Aug 10, 2026
ec35627
chore: apply suggestions from code review
vmphase Aug 11, 2026
ceb12e1
Merge branch 'master' into fix/3331
vmphase Sep 12, 2026
2d1c240
chore: apply review request
vmphase Sep 15, 2026
27096cd
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ These changes are available on the `master` branch, but have not yet been releas

### Changed

- Changed `Label.set_radio_group()` and `Label.set_file_upload()` to no longer accept a
nullable `required` value.
([#3337](https://github.com/Pycord-Development/pycord/pull/3337))

### Fixed

- Fix `TypeError` when accessing `ApplicationCommand.guild_only` or
`SlashCommandGroup.guild_only` when `contexts` is `None`.
([#3320](https://github.com/Pycord-Development/pycord/pull/3320))
- Fix `TypeError` in `Label.set_radio_group()` and `Label.set_checkbox_group()` when
providing the `option` keyword argument.
([#3337](https://github.com/Pycord-Development/pycord/pull/3337))
- Fix `SyntaxWarning` about `return` in a `finally` block raised on Python 3.14+
([#3332](https://github.com/Pycord-Development/pycord/pull/3334))
- Fix `ScheduledEvent.subscriber_count` being incremented instead of decremented when a
Expand Down
5 changes: 3 additions & 2 deletions discord/ui/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Checkbox(ModalItem):
----------
custom_id: Optional[:class:`str`]
The ID of the checkbox that gets received during an interaction.
default: Optional[:class:`bool`]
Whether this checkbox is selected by default or not.
default: :class:`bool`
Whether this checkbox is selected by default or not. Defaults to ``False``.
id: Optional[:class:`int`]
The checkbox's ID.
"""
Expand All @@ -71,6 +71,7 @@ def __init__(
raise TypeError(
f"expected custom_id to be str, not {custom_id.__class__.__name__}"
)

if not isinstance(default, bool):
raise TypeError(f"default must be bool, not {default.__class__.__name__}")
Comment thread
vmphase marked this conversation as resolved.
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
Expand Down
3 changes: 2 additions & 1 deletion discord/ui/checkbox_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CheckboxGroup(ModalItem):
max_values: Optional[:class:`int`]
The maximum number of options that can be selected.
Must be between 1 and 10, inclusive.
required: Optional[:class:`bool`]
required: :class:`bool`
Whether an option selection is required or not. Defaults to ``True``.
id: Optional[:class:`int`]
The checkbox group's ID.
Expand Down Expand Up @@ -95,6 +95,7 @@ def __init__(
raise TypeError(
f"expected custom_id to be str, not {custom_id.__class__.__name__}"
)

if not isinstance(required, bool):
raise TypeError(f"required must be bool not {required.__class__.__name__}")
Comment thread
vmphase marked this conversation as resolved.
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
Expand Down
5 changes: 3 additions & 2 deletions discord/ui/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FileUpload(ModalItem):
max_values: Optional[:class:`int`]
The maximum number of files that can be uploaded.
Must be between 1 and 10, inclusive.
required: Optional[:class:`bool`]
required: :class:`bool`
Whether the file upload field is required or not. Defaults to ``True``.
id: Optional[:class:`int`]
The file upload field's ID.
Expand Down Expand Up @@ -86,8 +86,9 @@ def __init__(
raise TypeError(
f"expected custom_id to be str, not {custom_id.__class__.__name__}"
)

if not isinstance(required, bool):
raise TypeError(f"required must be bool not {required.__class__.__name__}") # type: ignore
raise TypeError(f"required must be bool not {required.__class__.__name__}")
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
self._attachments: list[Attachment] | None = None

Expand Down
31 changes: 11 additions & 20 deletions discord/ui/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,13 @@
CheckboxGroupOption,
)
from ..components import Label as LabelComponent
from ..components import (
RadioGroupOption,
SelectDefaultValue,
SelectOption,
_component_factory,
)
from ..enums import ButtonStyle, ChannelType, ComponentType, InputTextStyle
from ..utils import find, get
from .button import Button
from ..components import RadioGroupOption, SelectDefaultValue, SelectOption
from ..enums import ChannelType, ComponentType, InputTextStyle
from .checkbox import Checkbox
from .checkbox_group import CheckboxGroup
from .file_upload import FileUpload
from .input_text import InputText
from .item import ItemCallbackType, ModalItem
from .item import ModalItem
from .radio_group import RadioGroup
from .select import Select

Expand All @@ -53,9 +46,7 @@
if TYPE_CHECKING:
from typing_extensions import Self

from ..emoji import AppEmoji, GuildEmoji
from ..interactions import Interaction
from ..partial_emoji import PartialEmoji, _EmojiTag
from ..types.components import LabelComponent as LabelComponentPayload
from .modal import DesignerModal

Expand Down Expand Up @@ -264,7 +255,7 @@ def set_select(
options: list[SelectOption] | None = ...,
required: bool = ...,
id: int | None = ...,
) -> None: ...
) -> Self: ...

@overload
def set_select(
Expand All @@ -279,7 +270,7 @@ def set_select(
required: bool = ...,
id: int | None = ...,
default_values: Sequence[SelectDefaultValue] | None = ...,
) -> None: ...
) -> Self: ...

@overload
def set_select(
Expand All @@ -297,7 +288,7 @@ def set_select(
required: bool = ...,
id: int | None = ...,
default_values: Sequence[SelectDefaultValue] | None = ...,
) -> None: ...
) -> Self: ...

def set_select(
self,
Expand Down Expand Up @@ -371,7 +362,7 @@ def set_file_upload(
custom_id: str | None = None,
min_values: int | None = None,
max_values: int | None = None,
required: bool | None = True,
required: bool = True,
id: int | None = None,
) -> Self:
"""Set this label's item to a file upload.
Expand All @@ -389,7 +380,7 @@ def set_file_upload(
max_values: Optional[:class:`int`]
The maximum number of files that can be uploaded.
Must be between 1 and 10, inclusive.
required: Optional[:class:`bool`]
required: :class:`bool`
Whether the file upload field is required or not. Defaults to ``True``.
id: Optional[:class:`int`]
The file upload field's ID.
Expand All @@ -410,7 +401,7 @@ def set_radio_group(
*,
custom_id: str | None = None,
options: list[RadioGroupOption] | None = None,
required: bool | None = True,
required: bool = True,
id: int | None = None,
) -> Self:
"""Set this label's item to a radio group.
Expand All @@ -432,7 +423,7 @@ def set_radio_group(

radio = RadioGroup(
custom_id=custom_id,
option=options,
options=options,
required=required,
id=id,
)
Expand Down Expand Up @@ -474,7 +465,7 @@ def set_checkbox_group(

checkboxes = CheckboxGroup(
custom_id=custom_id,
option=options,
options=options,
min_values=min_values,
max_values=max_values,
required=required,
Expand Down
1 change: 1 addition & 0 deletions discord/ui/radio_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(
raise TypeError(
f"expected custom_id to be str, not {custom_id.__class__.__name__}"
)

if not isinstance(required, bool):
raise TypeError(f"required must be bool not {required.__class__.__name__}")
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
Expand Down
18 changes: 18 additions & 0 deletions discord/ui/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,24 @@ def __init__(
default_values: Sequence[SelectDefaultValue | ST] | None = ...,
) -> None: ...

@overload
Comment thread
NeloBlivion marked this conversation as resolved.
def __init__(
self,
select_type: ComponentType = ...,
*,
custom_id: str | None = ...,
placeholder: str | None = ...,
min_values: int = ...,
max_values: int = ...,
options: list[SelectOption] | None = ...,
channel_types: list[ChannelType] | None = ...,
disabled: bool = ...,
row: int | None = ...,
id: int | None = ...,
required: bool | None = ...,
default_values: Sequence[SelectDefaultValue | ST] | None = ...,
) -> None: ...

def __init__(
self,
select_type: ComponentType = ComponentType.string_select,
Expand Down