From 0c334839472940dcba32a10d9d9c0b5f495e412b Mon Sep 17 00:00:00 2001 From: Lloyd Date: Wed, 27 May 2026 20:16:23 +0100 Subject: [PATCH] refactor: clean up import statements and whitespace in local_cli, base, and update_endpoints modules --- repeater/local_cli.py | 8 ++++---- repeater/sensors/base.py | 1 - repeater/web/update_endpoints.py | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/repeater/local_cli.py b/repeater/local_cli.py index 9ee79d7..59225a6 100644 --- a/repeater/local_cli.py +++ b/repeater/local_cli.py @@ -8,7 +8,6 @@ import sys from typing import Optional from urllib.parse import urlparse - CONFIG_PATHS = [ "/etc/pymc_repeater/config.yaml", "config.yaml", @@ -25,9 +24,10 @@ def _validate_http_url(url: str) -> None: def _load_config(config_path=None): """Load repeater config.yaml, trying common paths.""" - import yaml from pathlib import Path + import yaml + paths = [config_path] if config_path else CONFIG_PATHS for p in paths: path = Path(p) @@ -41,9 +41,9 @@ def run_client_cli(host: str = "127.0.0.1", port: int = 8000, password: Optional """ Standalone CLI client that connects to a running repeater's HTTP API. """ - import urllib.request - import urllib.error import json + import urllib.error + import urllib.request base_url = f"http://{host}:{port}" diff --git a/repeater/sensors/base.py b/repeater/sensors/base.py index b14748d..faa9010 100644 --- a/repeater/sensors/base.py +++ b/repeater/sensors/base.py @@ -11,7 +11,6 @@ from abc import ABC, abstractmethod from datetime import datetime, timezone from typing import Any, Dict, Iterable, Optional, Tuple - _PIP_PACKAGE_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]*$") diff --git a/repeater/web/update_endpoints.py b/repeater/web/update_endpoints.py index 7ad5ee1..9810e97 100644 --- a/repeater/web/update_endpoints.py +++ b/repeater/web/update_endpoints.py @@ -32,6 +32,7 @@ from typing import List, Optional from urllib.parse import urlparse import cherrypy + from repeater.service_utils import get_container_restart_message, is_buildroot, is_container logger = logging.getLogger("HTTPServer") @@ -192,9 +193,10 @@ def _get_installed_version(force_refresh: bool = False) -> str: # If the running process is already on a higher version than anything found # on disk, the dist-info dirs are stale leftovers and __version__ is truth. try: - from repeater import __version__ as _running from packaging.version import Version + from repeater import __version__ as _running + if Version(_running) > Version(disk_version): # status() polls can call this frequently; throttle mismatch logs. global _disk_version_mismatch_logged