chore(V2): mypy clean — fix radice V2 nuovo + suppress mirato V1 legacy
- settings.py: lambda factory + type:ignore[call-arg] per env-loaded models
- routers/*.py (6 file): cast esplicito Environment / Client per request.state
- __main__.py: cast Literal env in builder, type:ignore Settings()
- server.py: type:ignore[method-assign] su app.openapi
- deribit/tools.py: assert su validator-normalized fields, list return type
- deribit/client.py: type:ignore mirato no-any-return / has-type, rinomina types→types_list
- hyperliquid/{client,tools}.py: assert su validator-normalized fields, var-annotated
- alpaca/client.py: type:ignore mirato per SDK quirks (assignment, no-any-return, arg-type, union-attr)
- {macro,sentiment}/fetchers.py: type:ignore mirato no-any-return / operator / union-attr
Mypy: 68 → 0 errors. Test: 259 passing. Ruff: clean.
This commit is contained in:
@@ -130,14 +130,14 @@ class AlpacaClient:
|
||||
|
||||
async def get_account(self) -> dict:
|
||||
acc = await self._run(self._trading.get_account)
|
||||
return _serialize(acc)
|
||||
return _serialize(acc) # type: ignore[no-any-return]
|
||||
|
||||
async def get_positions(self) -> list[dict]:
|
||||
pos = await self._run(self._trading.get_all_positions)
|
||||
return [_serialize(p) for p in pos]
|
||||
|
||||
async def get_activities(self, limit: int = 50) -> list[dict]:
|
||||
acts = await self._run(self._trading.get_account_activities)
|
||||
acts = await self._run(self._trading.get_account_activities) # type: ignore[union-attr]
|
||||
data = [_serialize(a) for a in acts]
|
||||
return data[:limit]
|
||||
|
||||
@@ -148,7 +148,7 @@ class AlpacaClient:
|
||||
) -> list[dict]:
|
||||
req = GetAssetsRequest(
|
||||
asset_class=_asset_class_enum(asset_class),
|
||||
status=status,
|
||||
status=status, # type: ignore[arg-type]
|
||||
)
|
||||
assets = await self._run(self._trading.get_all_assets, req)
|
||||
return [_serialize(a) for a in assets[:500]]
|
||||
@@ -175,10 +175,10 @@ class AlpacaClient:
|
||||
"timestamp": _serialize(getattr(trade, "timestamp", None)),
|
||||
}
|
||||
if ac == "crypto":
|
||||
req = CryptoLatestTradeRequest(symbol_or_symbols=symbol)
|
||||
req = CryptoLatestTradeRequest(symbol_or_symbols=symbol) # type: ignore[assignment]
|
||||
data = await self._run(self._crypto.get_crypto_latest_trade, req)
|
||||
trade = data.get(symbol)
|
||||
q_req = CryptoLatestQuoteRequest(symbol_or_symbols=symbol)
|
||||
q_req = CryptoLatestQuoteRequest(symbol_or_symbols=symbol) # type: ignore[assignment]
|
||||
qdata = await self._run(self._crypto.get_crypto_latest_quote, q_req)
|
||||
quote = qdata.get(symbol)
|
||||
return {
|
||||
@@ -190,7 +190,7 @@ class AlpacaClient:
|
||||
"timestamp": _serialize(getattr(trade, "timestamp", None)),
|
||||
}
|
||||
if ac == "options":
|
||||
req = OptionLatestQuoteRequest(symbol_or_symbols=symbol)
|
||||
req = OptionLatestQuoteRequest(symbol_or_symbols=symbol) # type: ignore[assignment]
|
||||
data = await self._run(self._option.get_option_latest_quote, req)
|
||||
quote = data.get(symbol)
|
||||
return {
|
||||
@@ -224,13 +224,13 @@ class AlpacaClient:
|
||||
)
|
||||
data = await self._run(self._stock.get_stock_bars, req)
|
||||
elif ac == "crypto":
|
||||
req = CryptoBarsRequest(
|
||||
req = CryptoBarsRequest( # type: ignore[assignment]
|
||||
symbol_or_symbols=symbol, timeframe=tf,
|
||||
start=start_dt, end=end_dt, limit=limit,
|
||||
)
|
||||
data = await self._run(self._crypto.get_crypto_bars, req)
|
||||
elif ac == "options":
|
||||
req = OptionBarsRequest(
|
||||
req = OptionBarsRequest( # type: ignore[assignment]
|
||||
symbol_or_symbols=symbol, timeframe=tf,
|
||||
start=start_dt, end=end_dt, limit=limit,
|
||||
)
|
||||
@@ -255,7 +255,7 @@ class AlpacaClient:
|
||||
async def get_snapshot(self, symbol: str) -> dict:
|
||||
req = StockSnapshotRequest(symbol_or_symbols=symbol)
|
||||
data = await self._run(self._stock.get_stock_snapshot, req)
|
||||
return _serialize(data.get(symbol))
|
||||
return _serialize(data.get(symbol)) # type: ignore[no-any-return]
|
||||
|
||||
async def get_option_chain(
|
||||
self,
|
||||
@@ -301,23 +301,23 @@ class AlpacaClient:
|
||||
"time_in_force": tif_enum,
|
||||
}
|
||||
if qty is not None:
|
||||
common["qty"] = qty
|
||||
common["qty"] = qty # type: ignore[assignment]
|
||||
if notional is not None:
|
||||
common["notional"] = notional
|
||||
common["notional"] = notional # type: ignore[assignment]
|
||||
if ot == "market":
|
||||
req = MarketOrderRequest(**common)
|
||||
elif ot == "limit":
|
||||
if limit_price is None:
|
||||
raise ValueError("limit_price required for limit order")
|
||||
req = LimitOrderRequest(**common, limit_price=limit_price)
|
||||
req = LimitOrderRequest(**common, limit_price=limit_price) # type: ignore[assignment]
|
||||
elif ot == "stop":
|
||||
if stop_price is None:
|
||||
raise ValueError("stop_price required for stop order")
|
||||
req = StopOrderRequest(**common, stop_price=stop_price)
|
||||
req = StopOrderRequest(**common, stop_price=stop_price) # type: ignore[assignment]
|
||||
else:
|
||||
raise ValueError(f"unsupported order_type: {order_type}")
|
||||
order = await self._run(self._trading.submit_order, req)
|
||||
return _serialize(order)
|
||||
return _serialize(order) # type: ignore[no-any-return]
|
||||
|
||||
async def amend_order(
|
||||
self,
|
||||
@@ -338,7 +338,7 @@ class AlpacaClient:
|
||||
kwargs["time_in_force"] = TimeInForce(tif.lower())
|
||||
req = ReplaceOrderRequest(**kwargs)
|
||||
order = await self._run(self._trading.replace_order_by_id, order_id, req)
|
||||
return _serialize(order)
|
||||
return _serialize(order) # type: ignore[no-any-return]
|
||||
|
||||
async def cancel_order(self, order_id: str) -> dict:
|
||||
await self._run(self._trading.cancel_order_by_id, order_id)
|
||||
@@ -364,7 +364,7 @@ class AlpacaClient:
|
||||
order = await self._run(
|
||||
self._trading.close_position, symbol, close_options=req
|
||||
)
|
||||
return _serialize(order)
|
||||
return _serialize(order) # type: ignore[no-any-return]
|
||||
|
||||
async def close_all_positions(self, cancel_orders: bool = True) -> list[dict]:
|
||||
resp = await self._run(
|
||||
@@ -376,7 +376,7 @@ class AlpacaClient:
|
||||
|
||||
async def get_clock(self) -> dict:
|
||||
clock = await self._run(self._trading.get_clock)
|
||||
return _serialize(clock)
|
||||
return _serialize(clock) # type: ignore[no-any-return]
|
||||
|
||||
async def get_calendar(
|
||||
self, start: str | None = None, end: str | None = None
|
||||
|
||||
Reference in New Issue
Block a user