Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ These changes are available on the `master` branch, but have not yet been releas
- 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 `Select.__init__` type overloads so that a non-literal `ComponentType` is
accepted. ([#3337](https://github.com/Pycord-Development/pycord/pull/3337))
- Fix `RadioGroup`, `CheckboxGroup`, and `FileUpload` not accepting `None` for the
`required` parameter.
([#3337](https://github.com/Pycord-Development/pycord/pull/3337))
- Fix `Checkbox` not accepting `None` for the `default` parameter.
([#3337](https://github.com/Pycord-Development/pycord/pull/3337))
- Fix the `option` keyword argument name to `options` in `Label.set_radio_group` and
`Label.set_checkbox_group`.
([#3337](https://github.com/Pycord-Development/pycord/pull/3337))

### Deprecated

Expand Down
6 changes: 3 additions & 3 deletions discord/ui/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ def __init__(
self,
*,
custom_id: str | None = None,
default: bool = False,
default: bool | None = None,
id: int | None = None,
):
super().__init__()
if custom_id is not None and not isinstance(custom_id, str):
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.

default = False if default is None else default
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
self._value: bool | None = None

Expand Down
6 changes: 3 additions & 3 deletions discord/ui/checkbox_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(
options: list[CheckboxGroupOption] | None = None,
min_values: int | None = None,
max_values: int | None = None,
required: bool = True,
required: bool | None = None,
id: int | None = None,
):
super().__init__()
Expand All @@ -95,8 +95,8 @@ 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.

required = True if required is None else required
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
self._selected_values: list[str] | None = None

Expand Down
6 changes: 3 additions & 3 deletions discord/ui/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
custom_id: str | None = None,
min_values: int | None = None,
max_values: int | None = None,
required: bool = True,
required: bool | None = None,
id: int | None = None,
):
super().__init__()
Expand All @@ -86,8 +86,8 @@ 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

required = True if required is None else required
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
self._attachments: list[Attachment] | None = None

Expand Down
10 changes: 5 additions & 5 deletions discord/ui/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def set_select(
options: list[SelectOption] | None = ...,
required: bool = ...,
id: int | None = ...,
) -> None: ...
) -> Self: ...

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

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

def set_select(
self,
Expand Down Expand Up @@ -432,7 +432,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 +474,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
6 changes: 3 additions & 3 deletions discord/ui/radio_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ def __init__(
*,
custom_id: str | None = None,
options: list[RadioGroupOption] | None = None,
required: bool = True,
required: bool | None = True,
id: int | None = None,
):
super().__init__()
if custom_id is not None and not isinstance(custom_id, str):
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__}")

required = True if required is None else required
custom_id = os.urandom(16).hex() if custom_id is None else custom_id
self._selected_value: str | None = None

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