Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/reachy_mini/daemon/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
from dataclasses import asdict, dataclass
from enum import Enum
from importlib.metadata import version
from threading import Event, Thread
from typing import Any, Optional

Expand Down Expand Up @@ -41,13 +42,22 @@ def __init__(self, log_level: str = "INFO", wireless_version: bool = False) -> N
self.wireless_version = wireless_version

self.backend: "RobotBackend | MujocoBackend | None" = None
# Get package version
try:
package_version = version("reachy_mini")
self.logger.info(f"Daemon version: {package_version}")
except Exception:
package_version = None
self.logger.warning("Could not determine daemon version")
Comment on lines +46 to +51
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception handling is too broad. importlib.metadata.version() specifically raises PackageNotFoundError when a package is not found. Consider catching the specific exception type instead of a bare Exception:

from importlib.metadata import PackageNotFoundError, version

# ...

try:
    package_version = version("reachy_mini")
    self.logger.info(f"Daemon version: {package_version}")
except PackageNotFoundError:
    package_version = None
    self.logger.warning("Could not determine daemon version")

This makes the error handling more precise and explicit about what failure case is being handled.

Copilot uses AI. Check for mistakes.

Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected. Please remove the trailing whitespace at the end of this line.

Suggested change

Copilot uses AI. Check for mistakes.
self._status = DaemonStatus(
state=DaemonState.NOT_INITIALIZED,
wireless_version=wireless_version,
simulation_enabled=None,
backend_status=None,
error=None,
wlan_ip=None,
version=package_version,
)
self._thread_event_publish_status = Event()

Expand Down Expand Up @@ -463,3 +473,4 @@ class DaemonStatus:
backend_status: Optional[RobotBackendStatus | MujocoBackendStatus]
error: Optional[str] = None
wlan_ip: Optional[str] = None
version: Optional[str] = None
Loading