fix: resolve linting and formatting issues for CI

- Use contextlib.suppress instead of try/except/pass (SIM105)
- Prefix unused fixture arguments with underscore (ARG002)
- Replace asyncio.TimeoutError with TimeoutError (UP041)
- Apply ruff formatting to all files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Selamy
2026-01-04 17:09:14 -05:00
co-authored by Claude Opus 4.5
parent a15086688a
commit 1f4f1fa557
31 changed files with 180 additions and 311 deletions
+6 -19
View File
@@ -76,9 +76,7 @@ def sample_metadata() -> MarketMetadata:
condition_id="market_abc123",
question="Will it rain tomorrow?",
description="Weather prediction market",
tokens=(
Token(token_id="token_123", outcome="Yes", price=Decimal("0.65")),
),
tokens=(Token(token_id="token_123", outcome="Yes", price=Decimal("0.65")),),
category="science",
)
@@ -310,9 +308,7 @@ class TestRiskScorerInit:
class TestWeightedScoreCalculation:
"""Tests for weighted score calculation."""
def test_no_signals_zero_score(
self, mock_redis: AsyncMock, sample_trade: TradeEvent
) -> None:
def test_no_signals_zero_score(self, mock_redis: AsyncMock, sample_trade: TradeEvent) -> None:
"""Test score is zero when no signals present."""
scorer = RiskScorer(mock_redis)
bundle = SignalBundle(trade_event=sample_trade)
@@ -358,10 +354,7 @@ class TestWeightedScoreCalculation:
score, count = scorer.calculate_weighted_score(bundle)
# 0.7 confidence * 0.35 weight + 0.7 * 0.25 niche weight = 0.42
expected = (
0.7 * DEFAULT_WEIGHTS["size_anomaly"]
+ 0.7 * DEFAULT_WEIGHTS["niche_market"]
)
expected = 0.7 * DEFAULT_WEIGHTS["size_anomaly"] + 0.7 * DEFAULT_WEIGHTS["niche_market"]
assert score == pytest.approx(expected)
assert count == 1
@@ -559,9 +552,7 @@ class TestDeduplication:
"""Tests for deduplication functionality."""
@pytest.mark.asyncio
async def test_check_and_set_dedup_new_key(
self, mock_redis: AsyncMock
) -> None:
async def test_check_and_set_dedup_new_key(self, mock_redis: AsyncMock) -> None:
"""Test dedup returns False for new key."""
mock_redis.set.return_value = True
@@ -572,9 +563,7 @@ class TestDeduplication:
mock_redis.set.assert_called_once()
@pytest.mark.asyncio
async def test_check_and_set_dedup_existing_key(
self, mock_redis: AsyncMock
) -> None:
async def test_check_and_set_dedup_existing_key(self, mock_redis: AsyncMock) -> None:
"""Test dedup returns True for existing key."""
mock_redis.set.return_value = False # Key exists, NX failed
@@ -632,9 +621,7 @@ class TestBatchAnalysis:
confidence=0.8,
factors={},
)
bundles.append(
SignalBundle(trade_event=trade, fresh_wallet_signal=signal)
)
bundles.append(SignalBundle(trade_event=trade, fresh_wallet_signal=signal))
assessments = await scorer.assess_batch(bundles)
+4 -12
View File
@@ -290,9 +290,7 @@ class TestVolumeImpactCalculation:
detector = SizeAnomalyDetector(mock_metadata_sync)
# Trade size $1000, daily volume $50000 = 2% impact
impact = detector._calculate_volume_impact(
Decimal("1000"), Decimal("50000")
)
impact = detector._calculate_volume_impact(Decimal("1000"), Decimal("50000"))
assert impact == pytest.approx(0.02)
def test_volume_impact_none_volume(self, mock_metadata_sync: AsyncMock) -> None:
@@ -309,9 +307,7 @@ class TestVolumeImpactCalculation:
impact = detector._calculate_volume_impact(Decimal("1000"), Decimal("0"))
assert impact == 0.0
def test_volume_impact_negative_volume(
self, mock_metadata_sync: AsyncMock
) -> None:
def test_volume_impact_negative_volume(self, mock_metadata_sync: AsyncMock) -> None:
"""Test volume impact returns 0 when volume is negative."""
detector = SizeAnomalyDetector(mock_metadata_sync)
@@ -422,9 +418,7 @@ class TestNicheMarketDetection:
class TestConfidenceScoring:
"""Tests for confidence score calculation."""
def test_confidence_volume_impact_only(
self, mock_metadata_sync: AsyncMock
) -> None:
def test_confidence_volume_impact_only(self, mock_metadata_sync: AsyncMock) -> None:
"""Test confidence with only volume impact."""
detector = SizeAnomalyDetector(mock_metadata_sync)
@@ -819,9 +813,7 @@ class TestBatchAnalysis:
assert len(signals) == 2
@pytest.mark.asyncio
async def test_analyze_batch_empty_list(
self, mock_metadata_sync: AsyncMock
) -> None:
async def test_analyze_batch_empty_list(self, mock_metadata_sync: AsyncMock) -> None:
"""Test batch analysis with empty list."""
detector = SizeAnomalyDetector(mock_metadata_sync)
signals = await detector.analyze_batch([])