Ruff-Cleanup: ganzes MC2-Repo lint-grün + projekt-passende ruff.toml
Die Ampel-Nachruestung deckte 317/337 vorbestehende ruff-Verstoesse im ganzen Repo auf. Aufgeraeumt: - ruff.toml: intentionale Muster als Projekt-Politik ausgenommen (BLE001 blind-except, S110/S112 try-except-pass/continue, PLW1510 subprocess-best-effort, B008 FastAPI- Depends/File-Idiom, EXE001 Shebang, + wenige Stil-Regeln). __init__.py-Re-Exports geschuetzt (F401). - ruff --fix: 128 mechanische (Import-Sortierung, PEP585/604-Annotationen, tote Imports, ueberfluessige noqa) auto-behoben. - 12 echte Reste von Hand: PERF402/102, PLC3002 (Lambda->walrus), ISC004 (String-Concat geklammert), F841/RUF059 (ungenutzte Vars), PIE810 (startswith-Tuple), UP031 (f-string), UP035 (veraltete typing-Imports). Ergebnis: 'ruff check .' = 0, 'compileall' grün. Kein Verhaltenswechsel (nur Stil/Modernisierung). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+4
-5
@@ -24,11 +24,10 @@ import re
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from mem0 import Memory
|
||||
from mem0.configs.llms.openai import OpenAIConfig
|
||||
from mem0.llms.openai import OpenAILLM
|
||||
from pydantic import BaseModel
|
||||
|
||||
log = logging.getLogger("mem0_service")
|
||||
|
||||
@@ -203,7 +202,7 @@ def health() -> dict:
|
||||
try:
|
||||
mem().get_all(filters={"user_id": USER_ID}, top_k=1)
|
||||
return {"ok": True}
|
||||
except Exception as exc: # noqa: BLE001
|
||||
except Exception as exc:
|
||||
raise HTTPException(503, f"mem0 nicht bereit: {exc}")
|
||||
|
||||
|
||||
@@ -230,7 +229,7 @@ def _rerank(query: str, items: list[dict]) -> list[dict]:
|
||||
ranked.append(item)
|
||||
# Nur übernehmen, wenn der Reranker ALLE Kandidaten bewertet hat (sonst Verlustgefahr).
|
||||
return ranked if len(ranked) == len(items) else items
|
||||
except Exception as exc: # noqa: BLE001 — Gedächtnis darf am Reranker nie scheitern
|
||||
except Exception as exc:
|
||||
log.debug("rerank übersprungen: %s", exc)
|
||||
return items
|
||||
|
||||
@@ -383,7 +382,7 @@ def classify_facts(facts: list[tuple[str, str]]) -> dict:
|
||||
{"role": "user", "content": "Fakten:\n" + body}],
|
||||
response_format={"type": "json_object"},
|
||||
)
|
||||
m = _re.search(r"\{.*\}", resp or "", _re.S)
|
||||
m = _re.search(r"\{.*\}", resp or "", _re.DOTALL)
|
||||
data = _json.loads(m.group(0)) if m else {}
|
||||
out: dict = {}
|
||||
for k, v in data.items():
|
||||
|
||||
Reference in New Issue
Block a user