Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type issues in options.py #1473

Merged
merged 16 commits into from
Jul 13, 2022
Merged
Prev Previous commit
Next Next commit
Revert commit added by mistake
This reverts commit e21f08d.
  • Loading branch information
Dorukyum committed Jul 6, 2022
commit b3bccda0c652734e3e9e14e8ad4ee67c05c1cf13
7 changes: 2 additions & 5 deletions discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,17 @@ def __init__(self, input_type: InputType = str, /, description: Optional[str] =

if self.input_type == SlashCommandOptionType.integer:
minmax_types = (int, type(None))
minmax_typehint = Optional[int]
elif self.input_type == SlashCommandOptionType.number:
minmax_types = (int, float, type(None))
minmax_typehint = Optional[Union[int, float]]
else:
minmax_types = (type(None),)
minmax_typehint = type(None)
minmax_typehint = Optional[Union[minmax_types]] # type: ignore

if self.input_type == SlashCommandOptionType.string:
minmax_length_types = (int, type(None))
minmax_length_typehint = Optional[int]
else:
minmax_length_types = (type(None),)
minmax_length_typehint = type(None)
minmax_length_typehint = Optional[Union[minmax_length_types]] # type: ignore

self.min_value: minmax_typehint = kwargs.pop("min_value", None)
self.max_value: minmax_typehint = kwargs.pop("max_value", None)
Expand Down