Skip to content

Commit

Permalink
Range.__str__ always returns a string (#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor-S committed Jan 24, 2024
1 parent bdf4a3c commit 04ebca1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dstack/_internal/core/models/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __str__(self):
min = self.min if self.min is not None else ""
max = self.max if self.max is not None else ""
if min == max:
return min
return f"{min}"
return f"{min}..{max}"


Expand Down
3 changes: 3 additions & 0 deletions src/tests/_internal/core/models/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def test_unordered(self):
with pytest.raises(ValidationError):
parse_obj_as(Range[int], "3..1")

def test__str__(self):
assert isinstance(str(parse_obj_as(Range[int], "1")), str)


class TestMemoryRange:
def test_mb(self):
Expand Down

0 comments on commit 04ebca1

Please sign in to comment.