Explorar o código

fix(lint): resolve Ruff errors in dune-weaver-touch

- Remove unused imports: QTouchEvent, QMouseEvent, QQmlContext (F401)
- Move load_dotenv() call after all imports to fix E402
- Remove f-string prefix from strings with no placeholders (F541)
- Replace bare except with except Exception (E722)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris hai 6 días
pai
achega
a36cfadb5a
Modificáronse 2 ficheiros con 8 adicións e 8 borrados
  1. 3 3
      dune-weaver-touch/backend.py
  2. 5 5
      dune-weaver-touch/main.py

+ 3 - 3
dune-weaver-touch/backend.py

@@ -789,7 +789,7 @@ class Backend(QObject):
                 if isinstance(screen_timeout, (int, float)) and screen_timeout >= 0:
                     self._screen_timeout = int(screen_timeout)
                     if screen_timeout == 0:
-                        logger.debug(f"Loaded screen timeout from local settings: Never (0s)")
+                        logger.debug("Loaded screen timeout from local settings: Never (0s)")
                     else:
                         logger.debug(f"Loaded screen timeout from local settings: {self._screen_timeout}s")
                 else:
@@ -802,7 +802,7 @@ class Backend(QObject):
                 self._playlist_clear_pattern = settings.get('playlist_clear_pattern', "adaptive")
                 logger.info(f"Loaded playlist settings: pause={self._pause_between_patterns}s, shuffle={self._playlist_shuffle}, mode={self._playlist_run_mode}, clear={self._playlist_clear_pattern}")
             else:
-                logger.debug(f"No local settings file found, creating with defaults")
+                logger.debug("No local settings file found, creating with defaults")
                 self._save_local_settings()
         except Exception as e:
             logger.error(f"Error loading local settings: {e}, using defaults")
@@ -1137,7 +1137,7 @@ class Backend(QObject):
                                               shell=True, capture_output=True, text=True, timeout=2)
                         if result.returncode == 0 and result.stdout.strip():
                             max_brightness = int(result.stdout.strip())
-                    except:
+                    except Exception:
                         pass
                     
                     subprocess.run(['sudo', 'sh', '-c', 

+ 5 - 5
dune-weaver-touch/main.py

@@ -6,19 +6,19 @@ import time
 import signal
 from pathlib import Path
 from PySide6.QtCore import QUrl, QTimer, QObject, QEvent
-from PySide6.QtGui import QGuiApplication, QTouchEvent, QMouseEvent
-from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType, QQmlContext
+from PySide6.QtGui import QGuiApplication
+from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType
 from qasync import QEventLoop
-
-# Load environment variables from .env file if it exists
 from dotenv import load_dotenv
-load_dotenv(Path(__file__).parent / ".env")
 
 from backend import Backend
 from models.pattern_model import PatternModel
 from models.playlist_model import PlaylistModel
 from png_cache_manager import ensure_png_cache_startup
 
+# Load environment variables from .env file if it exists
+load_dotenv(Path(__file__).parent / ".env")
+
 # Configure logging
 logging.basicConfig(
     level=logging.INFO,