Skip to content

Commit 5a377de

Browse files
authored
fix: Truncate debug strings for MapContent (#564)
* Truncate debug strings for MapContent * chore: apply github co-pilot recommendation
1 parent 8c91999 commit 5a377de

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

roborock/devices/traits/v1/map_content.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
_LOGGER = logging.getLogger(__name__)
1414

15+
_TRUNCATE_LENGTH = 20
16+
1517

1618
@dataclass
1719
class MapContent(RoborockBase):
@@ -23,6 +25,13 @@ class MapContent(RoborockBase):
2325
map_data: MapData | None = None
2426
"""The parsed map data which contains metadata for points on the map."""
2527

28+
def __repr__(self) -> str:
29+
"""Return a string representation of the MapContent."""
30+
img = self.image_content
31+
if self.image_content and len(self.image_content) > _TRUNCATE_LENGTH:
32+
img = self.image_content[: _TRUNCATE_LENGTH - 3] + b"..."
33+
return f"MapContent(image_content={img!r}, map_data={self.map_data!r})"
34+
2635

2736
@common.map_rpc_channel
2837
class MapContentTrait(MapContent, common.V1TraitMixin):

0 commit comments

Comments
 (0)