You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LargeInt cannot be restricted like Range, and Range cannot be a big int.
What is the feature request for?
disnake.ext.commands
The Problem
LargeInt is an integer bigger than 2 ** 53, and Range only works on numbers below 2 ** 53. It would be nice to have a combination of the two, possibly even merge them into one class.
We also don't have LargeFloat right now, so a modified Range could potentially support that.
The Ideal Solution
Continue to keep LargeInt around, but merge support into Range. This means that if Range has more than the limit provided by discord, we instead use an underlying string type and manually compute the value. In order to constrain the value further, we should provide min_length and max_length computed to the length of the object.
For example:
# setup variables# for those wondering, these are the shortest and current longest possible snowflake valuesmin=int("1"+"0"*16)
max=int("9"*19)
commands.Range[min, max]
This would create a Range object that is rendered as a string but has a min_length set to 17, and a max_length set to 19, as that is how long the beginning number and second number are after converted to a string. After that we would compute the limitations as normal once we received an interaction. We should also keep in mind python/cpython#95778
The Current Solution
None
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Since #991 made commands.Range require taking the actual type as first param, I think making it take LargeInt would be a natural solution to this issue: commands.Range[LargeInt, min, max]
Exceeding the bounds on normal int should raise an error, telling the user to use LargeInt if they really want the greater range
This way it's an explicit opt-in to use a string type to represent larger numbers
Enegg
linked a pull request
Jun 2, 2024
that will
close
this issue
Summary
LargeInt cannot be restricted like Range, and Range cannot be a big int.
What is the feature request for?
disnake.ext.commands
The Problem
LargeInt is an integer bigger than 2 ** 53, and Range only works on numbers below 2 ** 53. It would be nice to have a combination of the two, possibly even merge them into one class.
We also don't have LargeFloat right now, so a modified Range could potentially support that.
The Ideal Solution
Continue to keep LargeInt around, but merge support into Range. This means that if Range has more than the limit provided by discord, we instead use an underlying string type and manually compute the value. In order to constrain the value further, we should provide min_length and max_length computed to the length of the object.
For example:
This would create a Range object that is rendered as a string but has a min_length set to 17, and a max_length set to 19, as that is how long the beginning number and second number are after converted to a string. After that we would compute the limitations as normal once we received an interaction. We should also keep in mind python/cpython#95778
The Current Solution
None
Additional Context
No response
The text was updated successfully, but these errors were encountered: