-
Notifications
You must be signed in to change notification settings - Fork 147
feat(commands): Add support for Range[LargeInt, ...]
#1201
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
base: master
Are you sure you want to change the base?
Conversation
Range[LargeInt, ...]Range[LargeInt, ...]
|
Tangentially related: we could add slice support for defining ranges ( |
|
Hi, would you please resolve conflicts? |
5fff87a to
dddeb46
Compare
5410c06 to
57f7855
Compare
disnake/ext/commands/params.py
Outdated
| return decorator | ||
|
|
||
|
|
||
| NumT = TypeVar("NumT", bound=Union[int, float]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on adding a default= to this typevar? Otherwise pyright infers annotation.min_value as Unknown | None below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty to instead move String/Range outside of TYPE_CHECKING, which allows pyright to actually typecheck their bodies, which in turn fixes the Unknown | None you mentioned.
Seems like this broke Sphinx though, would like some help resolving that :^)
Co-authored-by: vi <[email protected]> Signed-off-by: Eneg <[email protected]>
…nto Eneg/large-range

Summary
Closes #787
This PR adds support for defining a range of accepted values for
commands.LargeInt.If both bounds are specified, we restrict the length of the string input according to the number of digits (and sign) of the bounds.
We also raise an error during conversion, if the provided value would exceed the defined range (for example
Range[LargeInt, 100, 200]would have actual possible input of 100-999).I've also implemented a check in case the developer attempts to define a range exceeding ±2**53 with the normal
inttype, directing them toLargeInt.Checklist
pdm lintpdm pyright