mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 10:25:28 +00:00
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 <liangwen12year@gmail.com>
This commit is contained in:
parent
93e509b533
commit
dfacbf72f7
1 changed files with 3 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue