mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Fix TimedeltaConverter allowing negative values by default (#6354)
Co-authored-by: zephyrkul <zephyrkul@users.noreply.github.com>
This commit is contained in:
parent
00e41d38f9
commit
11ebd40dfa
@ -334,6 +334,7 @@ else:
|
|||||||
If provided, any parsed value higher than this will raise an exception
|
If provided, any parsed value higher than this will raise an exception
|
||||||
minimum : Optional[datetime.timedelta]
|
minimum : Optional[datetime.timedelta]
|
||||||
If provided, any parsed value lower than this will raise an exception
|
If provided, any parsed value lower than this will raise an exception
|
||||||
|
Defaults to 0 seconds, pass None explicitly to allow negative values
|
||||||
allowed_units : Optional[List[str]]
|
allowed_units : Optional[List[str]]
|
||||||
If provided, you can constrain a user to expressing the amount of time
|
If provided, you can constrain a user to expressing the amount of time
|
||||||
in specific units. The units you can choose to provide are the same as the
|
in specific units. The units you can choose to provide are the same as the
|
||||||
@ -344,7 +345,14 @@ else:
|
|||||||
apply.
|
apply.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, minimum=None, maximum=None, allowed_units=None, default_unit=None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
minimum=timedelta(seconds=0),
|
||||||
|
maximum=None,
|
||||||
|
allowed_units=None,
|
||||||
|
default_unit=None,
|
||||||
|
):
|
||||||
self.allowed_units = allowed_units
|
self.allowed_units = allowed_units
|
||||||
self.default_unit = default_unit
|
self.default_unit = default_unit
|
||||||
self.minimum = minimum
|
self.minimum = minimum
|
||||||
@ -372,7 +380,7 @@ if TYPE_CHECKING:
|
|||||||
*,
|
*,
|
||||||
default_unit: Optional[str] = None,
|
default_unit: Optional[str] = None,
|
||||||
maximum: Optional[timedelta] = None,
|
maximum: Optional[timedelta] = None,
|
||||||
minimum: Optional[timedelta] = None,
|
minimum: Optional[timedelta] = timedelta(seconds=0),
|
||||||
allowed_units: Optional[List[str]] = None,
|
allowed_units: Optional[List[str]] = None,
|
||||||
) -> Type[timedelta]:
|
) -> Type[timedelta]:
|
||||||
...
|
...
|
||||||
@ -383,7 +391,7 @@ else:
|
|||||||
*,
|
*,
|
||||||
default_unit: Optional[str] = None,
|
default_unit: Optional[str] = None,
|
||||||
maximum: Optional[timedelta] = None,
|
maximum: Optional[timedelta] = None,
|
||||||
minimum: Optional[timedelta] = None,
|
minimum: Optional[timedelta] = timedelta(seconds=0),
|
||||||
allowed_units: Optional[List[str]] = None,
|
allowed_units: Optional[List[str]] = None,
|
||||||
) -> Type[timedelta]:
|
) -> Type[timedelta]:
|
||||||
"""
|
"""
|
||||||
@ -398,6 +406,7 @@ else:
|
|||||||
If provided, any parsed value higher than this will raise an exception
|
If provided, any parsed value higher than this will raise an exception
|
||||||
minimum : Optional[datetime.timedelta]
|
minimum : Optional[datetime.timedelta]
|
||||||
If provided, any parsed value lower than this will raise an exception
|
If provided, any parsed value lower than this will raise an exception
|
||||||
|
Defaults to 0 seconds, pass None explicitly to allow negative values
|
||||||
allowed_units : Optional[List[str]]
|
allowed_units : Optional[List[str]]
|
||||||
If provided, you can constrain a user to expressing the amount of time
|
If provided, you can constrain a user to expressing the amount of time
|
||||||
in specific units. The units you can choose to provide are the same as the
|
in specific units. The units you can choose to provide are the same as the
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user