fix: repair seven undefined names and make CI ruff step meaningful

`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 <noreply@anthropic.com>
This commit is contained in:
Hermes Team 2026-08-20 22:28:08 +07:00
parent 46a185395c
commit 63c0385f5c
5 changed files with 24 additions and 7 deletions

View file

@ -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"]

View file

@ -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 [

View file

@ -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 "Квота: доступна",

View file

@ -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

View file

@ -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