Fix linting issues: line length, import sorting, unused variables

- Set ruff/black line length to 120
- Reformatted code with black
- Fixed import ordering with ruff
- Disabled lint for UI component files with long CSS strings
- Updated pyproject.toml with proper tool configuration
This commit is contained in:
Bu5hm4nn
2026-03-22 10:30:12 +01:00
parent b037bf4c01
commit 874b4a5a02
25 changed files with 456 additions and 195 deletions

View File

@@ -41,12 +41,28 @@ def sample_option_chain(sample_portfolio: LombardPortfolio) -> dict[str, object]
"updated_at": datetime(2026, 3, 21, 0, 0).isoformat(),
"source": "mock",
"calls": [
{"strike": round(spot * 1.05, 2), "premium": round(spot * 0.03, 2), "expiry": "2026-06-19"},
{"strike": round(spot * 1.10, 2), "premium": round(spot * 0.02, 2), "expiry": "2026-09-18"},
{
"strike": round(spot * 1.05, 2),
"premium": round(spot * 0.03, 2),
"expiry": "2026-06-19",
},
{
"strike": round(spot * 1.10, 2),
"premium": round(spot * 0.02, 2),
"expiry": "2026-09-18",
},
],
"puts": [
{"strike": round(spot * 0.95, 2), "premium": round(spot * 0.028, 2), "expiry": "2026-06-19"},
{"strike": round(spot * 0.90, 2), "premium": round(spot * 0.018, 2), "expiry": "2026-09-18"},
{
"strike": round(spot * 0.95, 2),
"premium": round(spot * 0.028, 2),
"expiry": "2026-06-19",
},
{
"strike": round(spot * 0.90, 2),
"premium": round(spot * 0.018, 2),
"expiry": "2026-09-18",
},
],
}
@@ -58,7 +74,10 @@ def mock_yfinance_data(monkeypatch):
# datetime.UTC symbol used in the data_service module.
from app.services import data_service as data_service_module
history = pd.DataFrame({"Close": [458.0, 460.0]}, index=pd.date_range("2026-03-20", periods=2, freq="D"))
history = pd.DataFrame(
{"Close": [458.0, 460.0]},
index=pd.date_range("2026-03-20", periods=2, freq="D"),
)
class FakeTicker:
def __init__(self, symbol: str) -> None:

View File

@@ -4,7 +4,7 @@ import pytest
import app.core.pricing.black_scholes as black_scholes
from app.strategies.base import StrategyConfig
from app.strategies.laddered_put import LadderSpec, LadderedPutStrategy
from app.strategies.laddered_put import LadderedPutStrategy, LadderSpec
from app.strategies.protective_put import ProtectivePutSpec, ProtectivePutStrategy
@@ -18,7 +18,10 @@ def test_protective_put_costs(
sample_strategy_config: StrategyConfig,
) -> None:
_force_analytic_pricing(monkeypatch)
strategy = ProtectivePutStrategy(sample_strategy_config, ProtectivePutSpec(label="ATM", strike_pct=1.0, months=12))
strategy = ProtectivePutStrategy(
sample_strategy_config,
ProtectivePutSpec(label="ATM", strike_pct=1.0, months=12),
)
cost = strategy.calculate_cost()
assert cost["strategy"] == "protective_put_atm"
@@ -35,7 +38,12 @@ def test_laddered_strategy(sample_strategy_config: StrategyConfig, monkeypatch:
_force_analytic_pricing(monkeypatch)
strategy = LadderedPutStrategy(
sample_strategy_config,
LadderSpec(label="50_50_ATM_OTM95", weights=(0.5, 0.5), strike_pcts=(1.0, 0.95), months=12),
LadderSpec(
label="50_50_ATM_OTM95",
weights=(0.5, 0.5),
strike_pcts=(1.0, 0.95),
months=12,
),
)
cost = strategy.calculate_cost()
protection = strategy.calculate_protection()
@@ -65,7 +73,12 @@ def test_scenario_analysis(
)
ladder = LadderedPutStrategy(
sample_strategy_config,
LadderSpec(label="50_50_ATM_OTM95", weights=(0.5, 0.5), strike_pcts=(1.0, 0.95), months=12),
LadderSpec(
label="50_50_ATM_OTM95",
weights=(0.5, 0.5),
strike_pcts=(1.0, 0.95),
months=12,
),
)
protective_scenarios = protective.get_scenarios()