From ea6cc65c0ae2aa7a19b1ae315db1af68325e4538 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:36:04 -0700 Subject: [PATCH] daemon: fixes for dataclass creation with python 3.11+ --- CHANGELOG.md | 1 + daemon/core/api/grpc/wrappers.py | 8 +++++--- daemon/core/emulator/data.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a020450d..c1d209ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * \#816 - fixed split link configuration saving to XML * \#823 - config services are now the default and only services available * \#842 - gRPC WLAN add node during runtime fixed + * \#875 - fix dataclass creation for python 3.11+ * core-gui * fixed copy/paste nodes to include image name * adds root to xhost by default when running diff --git a/daemon/core/api/grpc/wrappers.py b/daemon/core/api/grpc/wrappers.py index 3298ac7a..9627fa67 100644 --- a/daemon/core/api/grpc/wrappers.py +++ b/daemon/core/api/grpc/wrappers.py @@ -601,7 +601,7 @@ class Node: name: str = None type: NodeType = NodeType.DEFAULT model: str = None - position: Position = Position(x=0, y=0) + position: Position = field(default_factory=lambda: Position(x=0, y=0)) services: set[str] = field(default_factory=set) emane: str = None icon: str = None @@ -729,8 +729,10 @@ class Session: dir: str = None user: str = None default_services: dict[str, set[str]] = field(default_factory=dict) - location: SessionLocation = SessionLocation( - x=0.0, y=0.0, z=0.0, lat=47.57917, lon=-122.13232, alt=2.0, scale=150.0 + location: SessionLocation = field( + default_factory=lambda: SessionLocation( + x=0.0, y=0.0, z=0.0, lat=47.57917, lon=-122.13232, alt=2.0, scale=150.0 + ) ) hooks: dict[str, Hook] = field(default_factory=dict) metadata: dict[str, str] = field(default_factory=dict) diff --git a/daemon/core/emulator/data.py b/daemon/core/emulator/data.py index 525751ed..910bb8e9 100644 --- a/daemon/core/emulator/data.py +++ b/daemon/core/emulator/data.py @@ -231,7 +231,7 @@ class LinkData: network_id: int = None iface1: InterfaceData = None iface2: InterfaceData = None - options: LinkOptions = LinkOptions() + options: LinkOptions = field(default_factory=LinkOptions) color: str = None source: str = None