From 34c4ccb199e9975ef5c5713a06fab2aff3259089 Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 27 Nov 2024 13:26:17 -0500 Subject: [PATCH] Always specify magnitude for Range values Otherwise, the expression relies on str to render a Fraction value as a stringifiable number. The parsing of the value prevents this from not happening. Signed-off-by: mulhern --- src/stratis_cli/_actions/_logical.py | 6 +++--- src/stratis_cli/_parser/_range.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/stratis_cli/_actions/_logical.py b/src/stratis_cli/_actions/_logical.py index 6c763fc2a..fac3c52f5 100644 --- a/src/stratis_cli/_actions/_logical.py +++ b/src/stratis_cli/_actions/_logical.py @@ -78,13 +78,13 @@ def create_volumes(namespace): requested_size_arg = ( (False, "") if namespace.size is None - else (True, str(namespace.size.magnitude)) + else (True, namespace.size.magnitude.numerator) ) requested_size_limit_arg = ( (False, "") if namespace.size_limit is None - else (True, str(namespace.size_limit.magnitude)) + else (True, namespace.size_limit.magnitude.numerator) ) requested_specs = [ @@ -307,7 +307,7 @@ def set_size_limit(namespace): # pylint: disable=too-many-locals ) Filesystem.Properties.SizeLimit.Set( - get_object(fs_object_path), (True, new_limit.magnitude) + get_object(fs_object_path), (True, new_limit.magnitude.numerator) ) @staticmethod diff --git a/src/stratis_cli/_parser/_range.py b/src/stratis_cli/_parser/_range.py index 713745c97..c70d8c2d7 100644 --- a/src/stratis_cli/_parser/_range.py +++ b/src/stratis_cli/_parser/_range.py @@ -72,7 +72,11 @@ def parse_range(values): units = _unit_map(unit) - return Range(int(magnitude), units) + result = Range(int(magnitude), units) + + assert result.magnitude.denominator == 1 + + return result class RejectAction(argparse.Action):