Skip to content

Commit

Permalink
Always specify magnitude for Range values
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mulkieran committed Nov 27, 2024
1 parent 51bc9d7 commit 4148a39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/stratis_cli/_actions/_logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/stratis_cli/_parser/_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def parse_range(values):

units = _unit_map(unit)

return Range(int(magnitude), units)
result = Range(int(magnitude), units)

assert result.denominator == 1

return result


class RejectAction(argparse.Action):
Expand Down

0 comments on commit 4148a39

Please sign in to comment.