8000 Use repr() for enum values in Feature.__repr__ (#1414) · python-kasa/python-kasa@48a07a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 48a07a2

Browse files
authored
Use repr() for enum values in Feature.__repr__ (#1414)
Instead of simply displaying the enum value, use repr to get a nicer output for the cli. Was: `Error (vacuum_error): 14` Now: `Error (vacuum_error): <ErrorCode.DustBinRemoved: 14>`
1 parent 6aa0192 commit 48a07a2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kasa/feature.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ def __repr__(self) -> str:
295295
if self.precision_hint is not None and isinstance(value, float):
296296
value = round(value, self.precision_hint)
297297

298+
if isinstance(value, Enum):
299+
value = repr(value)
298300
s = f"{self.name} ({self.id}): {value}"
299301
if self.unit is not None:
300302
s += f" {self.unit}"

0 commit comments

Comments
 (0)
0