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

[SOLVED] TypeError: '<=' not supported between instances of 'int' and 'str' in Percentage.py #110

Open
sajho-dk opened this issue Sep 14, 2021 · 1 comment

Comments

@sajho-dk
Copy link

sajho-dk commented Sep 14, 2021

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
@pepper-jk
Copy link
Collaborator

pepper-jk commented Dec 2, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants