-
Notifications
You must be signed in to change notification settings - Fork 0
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
Parameter values of type int should also work with type float #67
Comments
Perhaps an extra flag like |
The first fix that comes to mind is (in class ValueTypeSchema(TypeSchema):
# ...
def validate(self, value) -> bool:
try:
self.type(value)
return True # Return true if the value can be converted to the type
except ValueError:
return False But this might be too permissive. For example, I think every value can be converted to boolean. Otherwise we could have a special case for float and int: def validate(self, value) -> bool:
return (self.type is float and type(value) is int) or self.type == type(value) But this might not work in other cases, if there are any. It depends on Python rules for implicit conversion. Reading online I did not find any other cases of implicit cast, so the special check might not be that bad. |
Allowing implicit conversion from int to float looks good to me. |
When calling
LoadGPTEnabled
, I have a situation where I'm passing2
into a parameter of typefloat
and it errors out when validating the type.The text was updated successfully, but these errors were encountered: