mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Disallow NaN and Infinity in Trivia CONFIG schema (#5949)
This commit is contained in:
parent
b493103dcb
commit
f13d910f66
@ -1,4 +1,5 @@
|
|||||||
import itertools
|
import itertools
|
||||||
|
import math
|
||||||
import re
|
import re
|
||||||
from typing import Any, NoReturn
|
from typing import Any, NoReturn
|
||||||
|
|
||||||
@ -18,8 +19,8 @@ class SchemaErrorMessage(str):
|
|||||||
|
|
||||||
|
|
||||||
def int_or_float(value: Any) -> float:
|
def int_or_float(value: Any) -> float:
|
||||||
if not isinstance(value, (float, int)):
|
if not isinstance(value, (float, int)) or not math.isfinite(value):
|
||||||
raise TypeError("Value needs to be an integer or a float.")
|
raise TypeError("Value needs to be an integer or a finite float.")
|
||||||
return float(value)
|
return float(value)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user