Skip to content

Commit

Permalink
fixup! fix(base_quantity): Removed string return from serialization o…
Browse files Browse the repository at this point in the history
…f pint quantity.
  • Loading branch information
pesap committed Jun 5, 2024
1 parent 4f03c6f commit 26521e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/infrasys/base_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _serialize(cls, input_value, info: SerializationInfo) -> float | str:
# We can add more logic that will change the serialization here.
magnitude_only = context.get("magnitude_only")
if magnitude_only:
return_value = return_value.magnitude
return return_value.magnitude
if info.mode == "json":
return_value = str(return_value)
return return_value
Expand Down
2 changes: 1 addition & 1 deletion tests/test_base_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def test_custom_serialization():
assert model_dump["voltage"] == 10.0

model_dump = component.model_dump(mode="json", context={"magnitude_only": True})
assert model_dump["voltage"] == "10.0"
assert model_dump["voltage"] == 10.0

0 comments on commit 26521e1

Please sign in to comment.