Skip to content

Commit 1bf9fae

Browse files
fix: Resolve type error when using --no-truncation on non-string values (#486)
## 📝 Description This change fixes a bug that would cause an error to be raised when attempting to disable truncation on certain commands. ## ✔️ How to Test ```bash make testunit ``` ```bash make install linode-cli linodes ls --no-truncation ```
1 parent 7018f45 commit 1bf9fae

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

linodecli/output.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ def _build_output_content(
260260
return content
261261

262262
def _attempt_truncate_value(self, value):
263-
if self.disable_truncation:
264-
return value
265-
266263
if not isinstance(value, str):
267264
value = str(value)
268265

266+
if self.disable_truncation:
267+
return value
268+
269269
if len(value) < self.truncation_length:
270270
return value
271271

tests/unit/test_output.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ def test_truncation(self, mock_cli):
320320

321321
assert result == test_str
322322

323+
# Ensure integers are properly converted
324+
result = mock_cli.output_handler._attempt_truncate_value(12345)
325+
326+
assert result == "12345"
327+
assert isinstance(result, str)
328+
323329
def test_truncated_table(self, mock_cli):
324330
output = io.StringIO()
325331

0 commit comments

Comments
 (0)