Skip to content

Commit

Permalink
squash: update the code
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed Jul 5, 2024
1 parent 05b58a4 commit 90b3132
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ def _from_specification(
as_quantity: bool = True,
as_cast: Optional[Callable[[str], ConstraintValueT]] = None,
original_constraint: Optional['Constraint[Any]'] = None,
allowed_operators: Optional[list[Operator]] = None
allowed_operators: Optional[list[Operator]] = None,
unit: Optional[Any] = "bytes"
) -> T:
"""
Parse raw constraint specification into our internal representation.
Expand Down Expand Up @@ -560,7 +561,7 @@ def _from_specification(
if not isinstance(
value,
pint.Quantity): # type: ignore[reportUnnecessaryIsInstance,unused-ignore]
value = pint.Quantity(value)
value = pint.Quantity(value, unit)

elif as_cast is not None:
value = as_cast(raw_value)
Expand Down Expand Up @@ -675,16 +676,13 @@ def from_specification(
allowed_operators: Optional[list[Operator]] = None,
unit: Optional[Any] = 'bytes'
) -> T:
if not isinstance(
UNITS(raw_value),
pint.Quantity): # type: ignore[reportUnnecessaryIsInstance,unused-ignore]
raw_value = str(pint.Quantity(raw_value, unit))
return cls._from_specification(
name,
raw_value,
as_quantity=True,
original_constraint=original_constraint,
allowed_operators=allowed_operators
allowed_operators=allowed_operators,
unit=unit
)


Expand Down

0 comments on commit 90b3132

Please sign in to comment.