From 63c0385f5cc35a046c8a05dbbf4819bb934d03cc Mon Sep 17 00:00:00 2001 From: Hermes Team Date: Thu, 20 Aug 2026 22:28:08 +0700 Subject: [PATCH] fix: repair seven undefined names and make CI ruff step meaningful MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ruff check .` failed on every push since CI was added (1221 findings), so the job aborted before pytest and the release gate ever ran. Adds [tool.ruff] selecting bug-catching rules only (E9, F63, F7, F82, F811); style and modernization rules stay off until their ~1200 findings are burned down. That selection immediately surfaced seven live defects: - hermes_hub_app: HubModal used but never imported, so the "Назначить" role modal raised NameError — the handler added to close an earlier review finding could never open. - hermes_hub_app: three `after(0, lambda: ...(e))` callbacks referencing the except-bound name, which Python unbinds at block exit, so every UI error path raised NameError instead of reporting the error. - auto_assigner: build_team_hierarchy referenced an undefined `is_main` and crashed on every call. - ui/assets and live_provision_and_validate: annotations naming Any/Tuple without importing them. Co-Authored-By: Claude Opus 5 --- pyproject.toml | 16 ++++++++++++++++ scripts/live_provision_and_validate.py | 2 +- src/antigravity_provider/router/auto_assigner.py | 3 ++- .../router/hermes_hub_app.py | 8 ++++---- src/antigravity_provider/router/ui/assets.py | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6c781a8..2d9428d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,3 +72,19 @@ markers = [ "installer: Tests verifying installer and packaging", "live: End-to-end tests requiring real user credentials", ] + +[tool.ruff] +line-length = 120 +target-version = "py310" +extend-exclude = ["legacy", ".venv"] + +[tool.ruff.lint] +# Bug-catching rules only, so CI gives a real signal today. +# E9 - syntax / IO errors F63 - comparison & assert mistakes +# F7 - misplaced statements F82 - undefined names +# F811 - redefinition of an in-use name +# Style and modernization rules (UP, I, BLE, S, SIM, RUF) are intentionally +# left off: the codebase currently has ~1200 such findings, and enabling them +# wholesale would keep CI red instead of catching defects. Burn them down in +# a dedicated pass, then extend this list. +select = ["E9", "F63", "F7", "F82", "F811"] diff --git a/scripts/live_provision_and_validate.py b/scripts/live_provision_and_validate.py index 7c49a5e..5617cab 100644 --- a/scripts/live_provision_and_validate.py +++ b/scripts/live_provision_and_validate.py @@ -14,7 +14,7 @@ import os import sys import time from pathlib import Path -from typing import Any, Dict, List, Optional +from typing import Tuple, Any, Dict, List, Optional REPO_ROOT = Path(__file__).resolve().parent.parent for p in [ diff --git a/src/antigravity_provider/router/auto_assigner.py b/src/antigravity_provider/router/auto_assigner.py index 75d631d..7beb300 100644 --- a/src/antigravity_provider/router/auto_assigner.py +++ b/src/antigravity_provider/router/auto_assigner.py @@ -335,7 +335,8 @@ class AutoAssigner: "provider_label": provider_label, "logical_role": log_role, "tier": tier, - "is_main": is_main, + "is_main": (pid == main_ag and pcfg.provider == "antigravity") + or (pid == main_codex and pcfg.provider == "openai-codex"), "identity": ident.primary_identifier() if is_auth else "Не авторизован", "plan": ident.plan.display_name if is_auth else "Тариф: неизвестен", "quota_str": relevant_bucket.formatted_remaining() if relevant_bucket else "Квота: доступна", diff --git a/src/antigravity_provider/router/hermes_hub_app.py b/src/antigravity_provider/router/hermes_hub_app.py index c58806b..ef360cf 100644 --- a/src/antigravity_provider/router/hermes_hub_app.py +++ b/src/antigravity_provider/router/hermes_hub_app.py @@ -47,7 +47,7 @@ from antigravity_provider.router.adapters import get_adapter from antigravity_provider.router.ui.theme import Theme from antigravity_provider.router.ui.assets import AssetManager -from antigravity_provider.router.ui.components import HubButton +from antigravity_provider.router.ui.components import HubButton, HubModal from antigravity_provider.router.ui.add_account_wizard import AddAccountWizard from antigravity_provider.router.unified_health import ( @@ -370,7 +370,7 @@ class HermesHubApp(ctk.CTk): except Exception as e: if not self._shutting_down: try: - self.after(0, lambda: self._on_data_error(str(e))) + self.after(0, lambda err=str(e): self._on_data_error(err)) except Exception: pass @@ -522,9 +522,9 @@ class HermesHubApp(ctk.CTk): if not self._shutting_down: try: if on_error: - self.after(0, lambda: on_error(str(e))) + self.after(0, lambda err=str(e): on_error(err)) else: - self.after(0, lambda: self._show_toast(f"❌ Ошибка: {e}")) + self.after(0, lambda err=str(e): self._show_toast(f"❌ Ошибка: {err}")) except Exception: pass diff --git a/src/antigravity_provider/router/ui/assets.py b/src/antigravity_provider/router/ui/assets.py index 48a4c9a..6f1d53d 100644 --- a/src/antigravity_provider/router/ui/assets.py +++ b/src/antigravity_provider/router/ui/assets.py @@ -3,7 +3,7 @@ from __future__ import annotations import os from pathlib import Path -from typing import Dict, Optional, Tuple +from typing import Any, Dict, Optional, Tuple try: from PIL import Image