From dfacbf72f70f70843d2115969d932145809d3af2 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Sun, 18 Apr 2021 09:39:44 -0400 Subject: [PATCH] arg_validator: normalize numeric value for ArgValidatorNum In python, bool is a subclass of int. Thus, isinstance(value, self.numeric_type) would be True, with value being a bool and numeric_type an int. ArgValidatorNum should normalize the input values to be of type self.numeric_type, except the default_value, which might be None (or anything really). Signed-off-by: Wen Liang --- module_utils/network_lsr/argument_validator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module_utils/network_lsr/argument_validator.py b/module_utils/network_lsr/argument_validator.py index f6c9253..45a9927 100644 --- a/module_utils/network_lsr/argument_validator.py +++ b/module_utils/network_lsr/argument_validator.py @@ -272,7 +272,9 @@ class ArgValidatorNum(ArgValidator): v = None try: if isinstance(value, self.numeric_type): - v = value + # ArgValidatorNum should normalize the input values to be of type + # self.numeric_type, except the default_value + v = self.numeric_type(value) else: v2 = self.numeric_type(value) if isinstance(value, Util.STRING_TYPE) or v2 == value: