style(rmi-backend): complete lint cleanup — 1175→0 ruff errors

- Fix 71 invalid-syntax files (class-body newline-broken assignments)
- Add from/None chain to 307 B904 raise-without-from sites
- Add B008 ignore to ruff.toml (already in pyproject.toml)
- Noqa F401 on __init__.py re-exports (137 sites)
- Noqa E402 on deferred imports (63 sites)
- Bulk-add stdlib/FastAPI/project imports for F821 (127 sites)
- Replace ×→x, –→-, …→... in docstrings (4093 chars)
- Manual refactor of 5 SIM103/SIM116 patterns

Tests: 791 passed (66 deselected due to pre-existing Redis issues in test_rag.py)
Co-authored-by: opencode <opencode@rugmunch.io>
This commit is contained in:
opencode 2026-07-06 15:43:20 +02:00
parent ca9bdce365
commit c762564d40
688 changed files with 5165 additions and 5142 deletions

View file

@ -13,11 +13,11 @@ from __future__ import annotations
from fastapi import APIRouter
# Aggregator list populated as domains migrate.
# Aggregator list - populated as domains migrate.
# Each entry is an APIRouter from app/api/v1/<group>/<domain>.py.
api_v1_router: list[APIRouter] = []
# Aggregator router single mount point for v1.
# Aggregator router - single mount point for v1.
# When domains migrate, replace this with a real aggregator:
# from app.api.v1.public import router as public_router
# api_v1_router.append(public_router)
@ -30,7 +30,7 @@ router = APIRouter(prefix="/api/v1", tags=["v1"])
#
# During strangelfig, the LEGACY /api/v1/<domain>/* endpoints remain
# mounted in main.py. The new v1 router is mounted at the same path
# (FastAPI handles prefix-based routing) first match wins, so the
# (FastAPI handles prefix-based routing) - first match wins, so the
# legacy stays until we explicitly remove it.
from app.api.v1.auth.alerts import router as alerts_router # noqa: E402

View file

@ -1,4 +1,4 @@
"""Admin routes admin role required.
"""Admin routes - admin role required.
Target: user management, system config, ops, bulletin moderation.
"""

View file

@ -1,4 +1,4 @@
"""Admin alerts webhook /api/v1/admin/alerts/webhook.
"""Admin alerts webhook - /api/v1/admin/alerts/webhook.
Stub endpoint for receiving alert webhooks from external sources
(monitoring, observability platforms).
@ -28,5 +28,5 @@ async def receive_alert_webhook(payload: AlertWebhookPayload) -> dict[str, Any]:
"""Receive an alert webhook from external monitoring."""
raise HTTPException(
status_code=501,
detail="Alert webhook ingestion not yet implemented pending T08 GlitchTip wiring",
detail="Alert webhook ingestion not yet implemented - pending T08 GlitchTip wiring",
)

View file

@ -1,4 +1,4 @@
"""Authenticated routes JWT required.
"""Authenticated routes - JWT required.
Target: portfolio, alerts, intel feeds, profile, settings.
"""

View file

@ -1,4 +1,4 @@
"""Auth alerts router /api/v1/alerts/*.
"""Auth alerts router - /api/v1/alerts/*.
Stub implementation for the alerts domain. Real implementations
will wire up to user-configured alert rules and notification channels
@ -52,7 +52,7 @@ async def create_alert(rule: AlertRule) -> dict[str, str]:
"""
raise HTTPException(
status_code=501,
detail="Alert persistence not yet implemented coming in v5.1",
detail="Alert persistence not yet implemented - coming in v5.1",
)
@ -61,5 +61,5 @@ async def delete_alert(rule_id: str) -> dict[str, str]:
"""Delete an alert rule by ID."""
raise HTTPException(
status_code=501,
detail="Alert persistence not yet implemented coming in v5.1",
detail="Alert persistence not yet implemented - coming in v5.1",
)

View file

@ -1,4 +1,4 @@
"""Catalog v1 routes thin HTTP layer."""
"""Catalog v1 routes - thin HTTP layer."""
from .router import router
__all__ = ["router"]

View file

@ -1,4 +1,4 @@
"""T27B HTTP routes CatalogService endpoints.
"""T27B HTTP routes - CatalogService endpoints.
Per v4.0 §T27. The thin HTTP layer over app.catalog.service.CatalogService.
"""
@ -66,7 +66,7 @@ async def get_token(chain: str, address: str) -> dict:
try:
c = Chain(chain)
except ValueError:
raise HTTPException(400, f"unknown chain: {chain}")
raise HTTPException(400, f"unknown chain: {chain}") from None
tok = await get_catalog().get_token(c, address)
if not tok:
raise HTTPException(404, "token not found")
@ -75,23 +75,23 @@ async def get_token(chain: str, address: str) -> dict:
@router.get("/tokens/{chain}/{address}/risk")
async def get_token_risk(chain: str, address: str) -> dict:
"""Recipe 3 Real-time risk score. Composes Redis + Postgres + Neo4j."""
"""Recipe 3 - Real-time risk score. Composes Redis + Postgres + Neo4j."""
try:
c = Chain(chain)
except ValueError:
raise HTTPException(400, f"unknown chain: {chain}")
raise HTTPException(400, f"unknown chain: {chain}") from None
return await get_catalog().get_token_risk(c, address)
@router.post("/tokens/risky-by-deployer")
async def risky_tokens(req: FindRiskyTokensRequest) -> dict:
"""Recipe 1 Find tokens deployed by wallets with rug history."""
"""Recipe 1 - Find tokens deployed by wallets with rug history."""
chain_enum = None
if req.chain:
try:
chain_enum = Chain(req.chain)
except ValueError:
raise HTTPException(400, f"unknown chain: {req.chain}")
raise HTTPException(400, f"unknown chain: {req.chain}") from None
tokens = await get_catalog().find_tokens_by_deployer_history(
min_rug_count=req.min_rug_count, chain=chain_enum, limit=req.limit
)
@ -107,7 +107,7 @@ async def get_wallet(chain: str, address: str) -> dict:
try:
c = Chain(chain)
except ValueError:
raise HTTPException(400, f"unknown chain: {chain}")
raise HTTPException(400, f"unknown chain: {chain}") from None
w = await get_catalog().get_wallet(c, address)
if not w:
raise HTTPException(404, "wallet not found")
@ -148,7 +148,7 @@ async def attach_rag(chain: str, address: str, req: AttachRagRequest) -> dict:
try:
c = Chain(chain)
except ValueError:
raise HTTPException(400, f"unknown chain: {chain}")
raise HTTPException(400, f"unknown chain: {chain}") from None
ok = await get_catalog().attach_rag_to_token(c, address, req.qdrant_point_id)
if not ok:
raise HTTPException(404, "token not found or update failed")

View file

@ -1,4 +1,4 @@
"""T33 MCP Server HTTP wrapper for SSE transport.
"""T33 MCP Server - HTTP wrapper for SSE transport.
Per v4.0 §T33. Endpoints:
POST /mcp JSON-RPC 2.0 endpoint
@ -68,7 +68,7 @@ async def jsonrpc_handler(req: JsonRpcRequest) -> dict:
"serverInfo": {
"name": "rugmunch-intelligence",
"version": MCP_SERVER_VERSION,
"description": "Crypto intelligence platform 13+ chains, 8 MCP tools, x402 paid tier",
"description": "Crypto intelligence platform - 13+ chains, 8 MCP tools, x402 paid tier",
},
"capabilities": {"tools": {}, "resources": {}, "prompts": {}},
},

View file

@ -1,4 +1,4 @@
"""Public routes no authentication required.
"""Public routes - no authentication required.
Target: scanner, wallet lookup, token info, pricing, health.
"""

View file

@ -1,4 +1,4 @@
"""Public scanner endpoints /api/v1/scanner/*.
"""Public scanner endpoints - /api/v1/scanner/*.
Stub for unauthenticated token scans. Real implementation will
trigger the scanner pipeline (honeypot detection, flash loan checks,
@ -37,7 +37,7 @@ async def scan(req: ScanRequest) -> ScanResult:
"""Queue a token/wallet scan."""
raise HTTPException(
status_code=501,
detail="Scanner pipeline not yet wired uses app.domain.scanner (T06+)",
detail="Scanner pipeline not yet wired - uses app.domain.scanner (T06+)",
)
@ -58,5 +58,5 @@ async def quick_scan(
"""Quick scan (free tier, no persistence)."""
raise HTTPException(
status_code=501,
detail="Quick scan uses cached shield see caching_shield module",
detail="Quick scan uses cached shield - see caching_shield module",
)

View file

@ -1,4 +1,4 @@
"""Public token endpoints /api/v1/token/*.
"""Public token endpoints - /api/v1/token/*.
Stub for unauthenticated token queries. Real implementation will
fetch token metadata, holders, liquidity, and risk score.
@ -43,7 +43,7 @@ async def get_token(
"""Fetch basic token metadata."""
raise HTTPException(
status_code=501,
detail="Token lookup not yet implemented coming in v5.1",
detail="Token lookup not yet implemented - coming in v5.1",
)
@ -52,7 +52,7 @@ async def get_token_risk(address: str, chain: str = "ethereum") -> TokenRisk:
"""Compute the risk score for a token (uses Bayesian reputation + on-chain checks)."""
raise HTTPException(
status_code=501,
detail="Token risk uses T01 Bayesian + T02 scanner pipeline pending wiring",
detail="Token risk uses T01 Bayesian + T02 scanner pipeline - pending wiring",
)
@ -61,5 +61,5 @@ async def get_token_holders(address: str, chain: str = "ethereum", top: int = 50
"""Return top holders distribution for a token."""
raise HTTPException(
status_code=501,
detail="Holder distribution not yet implemented uses Postgres + Neo4j",
detail="Holder distribution not yet implemented - uses Postgres + Neo4j",
)

View file

@ -1,4 +1,4 @@
"""Public wallet endpoints /api/v1/wallet/*.
"""Public wallet endpoints - /api/v1/wallet/*.
Stub for unauthenticated wallet queries. Real implementation will
resolve wallets, fetch labels, and return balance/history data.
@ -35,7 +35,7 @@ async def resolve_wallet(
"""
raise HTTPException(
status_code=501,
detail="Wallet resolution not yet implemented coming in v5.1",
detail="Wallet resolution not yet implemented - coming in v5.1",
)
@ -44,7 +44,7 @@ async def get_wallet_labels(address: str, chain: str = "ethereum") -> list[dict[
"""Return labels for a wallet from all federated sources."""
raise HTTPException(
status_code=501,
detail="Federated labels API pending see T11",
detail="Federated labels API pending - see T11",
)
@ -53,5 +53,5 @@ async def get_wallet_history(address: str, chain: str = "ethereum") -> dict[str,
"""Return transaction history summary for a wallet."""
raise HTTPException(
status_code=501,
detail="Wallet history pending uses Neo4j + Postgres in v5.1",
detail="Wallet history pending - uses Neo4j + Postgres in v5.1",
)

View file

@ -1,4 +1,4 @@
"""V1 RAG route thin HTTP layer over app.rag.
"""V1 RAG route - thin HTTP layer over app.rag.
The RAG system is the most coupled module (14 legacy files). This
facade exposes the most-used operations: search, ingest, feedback.

View file

@ -1,4 +1,4 @@
"""x402 paid routes crypto micropayment gated.
"""x402 paid routes - crypto micropayment gated.
Target: tools (split from legacy x402_tools.py), tokens, wallets, defi, security.
"""