ID2T
ID2T copied to clipboard
[SOLVED] TypeError: '<=' not supported between instances of 'int' and 'str' in Percentage.py
Hi, I realized that there is an issue in 'validate(self, value)' of code/Attack/ParameterTypes/Percentage.py. I have corrected the issue and commented the line with the error.
from Attack.ParameterTypes.BaseType import ParameterType
class Percentage(ParameterType):
def __init__(self):
super(Percentage, self).__init__()
self.name = "Percentage"
def validate(self, value) -> (bool, int):
#return Percentage._is_float(value)[0] and 0 <= value <= 1, value
res = Percentage._is_float(value)
return res[0] and 0 <= res[1] <= 1, res[1]
@staticmethod
def _is_float(value):
"""
Checks whether the given value is a float.
:param value: The value to be checked.
:return: True if the value is a float, otherwise False. And the casted float.
"""
try:
value = float(value)
return True, value
except ValueError:
return False, value
Hi, sorry for answering so late. Must have missed your post.
Could you provide the error you received before your changes?
I'd be happy to except pull request, as long as I am sure this doesn't break anything.