mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
arg_validator: rename ArgValidator.DEFAULT_SENTINEL to DEFAULT
To be consistent with ArgValidator.MISSING, which serves a similar purpose. Also, replace the if-else python ternary, which I find hard to read. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
03833e8ac2
commit
4afa81cdd0
1 changed files with 5 additions and 10 deletions
|
|
@ -87,7 +87,7 @@ class ValidationError(MyError):
|
|||
|
||||
class ArgValidator:
|
||||
MISSING = object()
|
||||
DEFAULT_SENTINEL = object()
|
||||
DEFAULT = object()
|
||||
|
||||
def __init__(self, name=None, required=False, default_value=None):
|
||||
self.name = name
|
||||
|
|
@ -253,17 +253,12 @@ class ArgValidatorNum(ArgValidator):
|
|||
required=False,
|
||||
val_min=None,
|
||||
val_max=None,
|
||||
default_value=ArgValidator.DEFAULT_SENTINEL,
|
||||
default_value=ArgValidator.DEFAULT,
|
||||
numeric_type=int,
|
||||
):
|
||||
ArgValidator.__init__(
|
||||
self,
|
||||
name,
|
||||
required,
|
||||
numeric_type(0)
|
||||
if default_value is ArgValidator.DEFAULT_SENTINEL
|
||||
else default_value,
|
||||
)
|
||||
if default_value is ArgValidator.DEFAULT:
|
||||
default_value = numeric_type(0)
|
||||
ArgValidator.__init__(self, name, required, default_value)
|
||||
self.val_min = val_min
|
||||
self.val_max = val_max
|
||||
self.numeric_type = numeric_type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue