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

feat(commands): Add support for Range[LargeInt, ...] #1201

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Enegg
Copy link
Contributor

@Enegg Enegg commented Jun 2, 2024

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 int type, directing them to LargeInt.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running pdm lint
    • I have type-checked the code by running pdm pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Enegg Enegg changed the title Add support for Range[LargeInt, ...] feat(commands): Add support for Range[LargeInt, ...] Jun 2, 2024
@shiftinv shiftinv added the t: enhancement New feature label Jun 4, 2024
@Enegg Enegg mentioned this pull request Jun 22, 2024
8 tasks
@DJStompZone
Copy link

@Enegg
Copy link
Contributor Author

Enegg commented Jun 24, 2024

Tangentially related: we could add slice support for defining ranges (Range[int, 0:32], String[str, :10]). Not sure how useful it'd be.

disnake/ext/commands/params.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: enhancement New feature
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

combine commands.LargeInt with commands.Range
3 participants