lint: ruff clean services/ (autofix + manual + ignore E741)
- 24 autofix safe (SIM105 contextlib.suppress, F401 unused imports, I001 import order, B007 unused loop var, F811 redef, F841 unused). - 15 unsafe-fix (UP038 X|Y in isinstance, SIM108 ternary, ecc.). - Manual fix: SIM102 nested if in deribit term_structure, E402 imports in test_cot.py + sentiment server.py. - Ignore E741 (variabili 'l' in list comprehensions deribit/client.py — stilistico, non bug). Tests: 478/478 verdi.
This commit is contained in:
@@ -21,6 +21,7 @@ Claude Code config esempio:
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
@@ -63,10 +64,8 @@ def _derive_input_schemas(app: FastAPI, tool_names: list[str]) -> dict[str, dict
|
||||
if pname == "return":
|
||||
continue
|
||||
if isinstance(ann, type) and issubclass(ann, BaseModel):
|
||||
try:
|
||||
with contextlib.suppress(Exception):
|
||||
out[name] = ann.model_json_schema()
|
||||
except Exception:
|
||||
pass
|
||||
break
|
||||
return out
|
||||
|
||||
|
||||
@@ -36,10 +36,7 @@ def orderbook_imbalance(
|
||||
ask_vol = sum(q for _, q in top_asks)
|
||||
total = bid_vol + ask_vol
|
||||
|
||||
if total == 0:
|
||||
ratio = None
|
||||
else:
|
||||
ratio = (bid_vol - ask_vol) / total
|
||||
ratio = None if total == 0 else (bid_vol - ask_vol) / total
|
||||
|
||||
# Microprice: best bid, best ask. Weighted by opposite-side size.
|
||||
microprice = None
|
||||
|
||||
@@ -4,7 +4,6 @@ import asyncio
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from mcp_common.http import async_client, call_with_retry
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ def test_vol_cone_returns_percentiles_per_window():
|
||||
closes = _gbm_series(mu=0.0, sigma=0.5, n=400)
|
||||
out = vol_cone(closes, windows=[10, 30, 60])
|
||||
assert set(out.keys()) == {10, 30, 60}
|
||||
for w, stats in out.items():
|
||||
for _w, stats in out.items():
|
||||
assert "current" in stats
|
||||
assert "p10" in stats and "p50" in stats and "p90" in stats
|
||||
assert stats["p10"] <= stats["p50"] <= stats["p90"]
|
||||
@@ -200,7 +200,7 @@ def test_autocorrelation_white_noise_low():
|
||||
assert len(out) == 5
|
||||
# white noise → all autocorr ≈ 0 (within ±2/sqrt(N))
|
||||
bound = 2.0 / math.sqrt(len(rets))
|
||||
for lag, val in out.items():
|
||||
for _lag, val in out.items():
|
||||
assert abs(val) < bound * 2 # generous
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user