Skip to content

Commit

Permalink
Fix mutable default values in dataclass
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
lafriks committed Oct 3, 2023
1 parent 563a092 commit e0065b6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions karcher/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class DeviceProperties:
main_brush: int = 0
side_brush: int = 0
mop_life: int = 0
net_status: DevicePropertiesNetwork = DevicePropertiesNetwork()
net_status: DevicePropertiesNetwork
repeat_state: int = 0
tank_state: int = 0
cloth_state: int = 0
Expand All @@ -121,7 +121,7 @@ class DeviceProperties:
charge_state: int = 0
back_to_wash: int = 0
break_charging: int = 0
order_total: DevicePropertiesOrderTotal = DevicePropertiesOrderTotal()
order_total: DevicePropertiesOrderTotal
memory_map: int = 0
current_map_id: int = 0
map_num: int = 0
Expand All @@ -131,15 +131,19 @@ class DeviceProperties:
quiet_begin_time: int = 0
quiet_end_time: int = 0
broken_clean: int = 0
privacy: DevicePropertiesPrivacy = DevicePropertiesPrivacy()
privacy: DevicePropertiesPrivacy
cur_path: List[float]
dust_action: int = 0
voice_type: int = 0
quiet_status: DevicePropertiesQuiet = DevicePropertiesQuiet()
quiet_status: DevicePropertiesQuiet
last_update_time: int = 0

def __init__(self, **kwargs):
setattr(self, 'cur_path', [])
setattr(self, 'net_stauts', DevicePropertiesNetwork())
setattr(self, 'order_total', DevicePropertiesOrderTotal())
setattr(self, 'privacy', DevicePropertiesPrivacy())
setattr(self, 'quiet_status', DevicePropertiesQuiet())
self.update(kwargs)

def update(self, data: dict[str, Any]) -> bool:
Expand Down

0 comments on commit e0065b6

Please sign in to comment.