fix: lint errors (import sorting, unused vars)

This commit is contained in:
Celes Renata
2026-04-14 19:48:19 +00:00
parent f7a11d14ea
commit d8ea58104c
19 changed files with 60 additions and 31 deletions
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/api/app.py
# hypothesis_version: 6.151.14
[0.0, 1.0, 30.0, 60.0, 100, 168, 200, 201, 400, 404, 502, 503, 504, 1000, 10000, ' AND ', '/api/analytics/query', '/api/companies', '/api/documents', '/api/macro/events', '/api/orders', '/api/positions', '/api/recommendations', '/api/trends', '/health', '/metrics', '1 day', '1 hour', '15 minutes', '15m', '1d', '1h', '6 hours', '6h', 'Company not found', 'DELETE 0', 'Database unavailable', 'Document not found', 'Order not found', 'Query not found', 'SELECT 1', 'Source not found', 'Trend not found', 'WHERE ', 'X-Trino-Catalog', 'X-Trino-Schema', 'X-Trino-User', '^(15m|1h|6h|1d)$', '__str__', 'active_source_count', 'affected_companies', 'aggregation', 'aliases', 'approved', 'audit_trail', 'by_source_type', 'c.active = $1', 'catalog', 'catalyst_type', 'columns', 'company', 'company_impacts', 'company_mentions', 'competitive_enabled', 'competitive_signals', 'competitor_ticker', 'config', 'contributing_factors', 'count', 'data', 'decision_trace', 'decisions', 'default', 'deleted', 'document_id', 'document_stages', 'dominant_catalysts', 'driving_factors', 'elapsed_ms', 'entity_type = $1', 'events', 'evidence', 'evidence_spans', 'extraction', 'extraction_warnings', 'generated_at', 'hours', 'id', 'intelligence', 'intelligence_id', 'key_facts', 'limit', 'macro.layer_toggled', 'macro_enabled', 'macro_themes', 'market_context', 'material_risks', 'message', 'mir.ticker = $1', 'missing_source_types', 'name', 'new_enabled', 'nextUri', 'ok', 'operator', 'order_job', 'paper', 'parsing', 'pattern_statistics', 'patterns', 'previous_enabled', 'projection', 'query_api', 'recommendation', 'recommendation_id', 'rejected', 'rejection_reasons', 'risk_checks', 'risk_config', 'risk_configs', 'risk_evaluation', 'risks', 'row_count', 'rows', 'schema', 'source', 'sql', 'sql is required', 'stale_sources', 'status', 'stonks-dashboard', 'tables', 'ticker', 'toggled_by', 'trading_mode', 'trend', 'trend_window', 'trend_window_id', 'true', 'type', 'unknown', 'validation_errors', 'x-trace-id']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/lake_publisher/jobs.py
# hypothesis_version: 6.151.14
[0.0, 2.0, ', ', '1d', '7d', 'Order %s not found', '__main__', 'active', 'affected_commodities', 'affected_regions', 'affected_sectors', 'ap', 'as', 'ask_price', 'ask_size', 'avg_entry_price', 'bar', 'bars', 'bid_price', 'bid_size', 'bidirectional', 'bp', 'broker_account', 'broker_timestamp', 'bs', 'bulk_documents', 'bulk_extractions', 'c', 'canonical_url', 'captured_at', 'catalyst_type', 'close', 'close_price', 'commission', 'company_a_id', 'company_b_id', 'company_event', 'company_id', 'company_name', 'competitive_signal', 'computed_at', 'confidence', 'content_hash', 'contributing_factors', 'created_at', 'current_price', 'data', 'document', 'document_extraction', 'document_id', 'document_type', 'driving_factors', 'en', 'entity_id', 'error', 'estimated_duration', 'event_id', 'event_types', 'execution_mode', 'extraction_at', 'fill_id', 'fill_price', 'fill_quantity', 'global_event', 'h', 'high', 'id', 'impact_direction', 'impact_horizon', 'impact_score', 'interval', 'job_type', 'key_facts', 'l', 'lake_publisher', 'language', 'last_price', 'last_size', 'limit_price', 'low', 'lp', 'ls', 'macro_impact', 'macro_impact_score', 'macro_themes', 'market_snapshot', 'model_name', 'model_version', 'n', 'neutral', 'novelty_score', 'o', 'open', 'order_id', 'order_type', 'other', 'parse_quality_score', 'pattern_confidence', 'pnl_snapshot', 'positions_snapshot', 'price', 'projected_confidence', 'projected_direction', 'projected_strength', 'projection_horizon', 'prompt_version', 'published_at', 'publisher', 'qty', 'quantity', 'quote', 'quotes', 'realized_pnl', 'recommendation_id', 'refs', 'relationship_type', 'relevance', 'retrieved_at', 'risks', 'schema_version', 'sentiment', 'severity', 'short_term', 'side', 'signal_direction', 'signal_strength', 'since', 'snapshot_type', 'source', 'source_credibility', 'source_document_id', 'source_provider', 'source_ticker', 'source_type', 'status', 'strength', 'submitted_at', 'summary', 'target_ticker', 'ticker', 'title', 'trade_count', 'trade_fill', 'trade_order', 'trend_projection', 'trend_window_id', 'unrealized_pnl', 'url', 'v', 'volume', 'vw', 'vwap', '{}']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/recommendation/worker.py
# hypothesis_version: 6.151.14
[0.0, 0.1, 0.15, 0.3, 0.5, 1.0, 1.5, 2.0, 3.0, ', ', '1.0.0', '; ', 'DIVERGENCE:', '[risk:', ']', '_', 'computed_at', 'confidence', 'contradiction_score', 'deterministic', 'document_id', 'dominant_catalysts', 'driving_factors', 'eligibility-v1', 'entity_id', 'entity_type', 'evidence', 'evidence_type', 'failed_documents', 'generated_at', 'high', 'id', 'low', 'material_risks', 'max_loss_pct', 'moderate', 'newest_evidence_at', 'none', 'ollama', 'opposing', 'portfolio_pct', 'position_sizing', 'projected_confidence', 'projected_direction', 'projected_strength', 'projection_horizon', 'risk_classification', 'source_types', 'supporting', 'thesis-rewrite', 'time_horizon', 'total_documents', 'trend_direction', 'trend_strength', 'valid_documents', 'very_high', 'weight', 'window']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/aggregation/projection.py
# hypothesis_version: 6.151.14
[-1.0, -0.1, 0.0, 0.02, 0.05, 0.1, 0.15, 0.25, 0.3, 0.4, 0.5, 0.75, 0.8, 0.85, 1.0, 1.2, 2.0, 7.0, 24.0, 30.0, '1d', '30d', '7d', '90d', 'bearish', 'bullish', 'critical', 'high', 'intraday', 'long_term', 'low', 'medium_term', 'mixed', 'moderate', 'negative', 'neutral', 'positive', 'projection', 'short_term']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/extractor/event_classifier.py
# hypothesis_version: 6.151.14
[0.0, 0.5, 1.0, '1.0.0', 'additionalProperties', 'affected_commodities', 'affected_regions', 'affected_sectors', 'application/json', 'array', 'confidence', 'description', 'document_id', 'empty_response', 'enum', 'error', 'estimated_duration', 'event_classifier', 'event_id', 'event_types', 'geopolitical_risk', 'items', 'json_schema', 'key_facts', 'low', 'maximum', 'minimum', 'model', 'number', 'object', 'ollama', 'parsed_event', 'prompt_version', 'properties', 'raw_output', 'required', 'schema_version', 'severity', 'short_term', 'stonks-llm-prompts', 'stonks-llm-results', 'string', 'success', 'summary', 'system', 'system_prompt', 'type', 'user', 'user_prompt']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/lake_publisher/iceberg.py
# hypothesis_version: 6.151.14
[8080, ',\n', ',\n ', ', ', 'BIGINT', 'BOOLEAN', 'DATE', 'DOUBLE', 'INTEGER', 'REAL', 'SMALLINT', 'TIMESTAMP(6)', 'TINYINT', 'VARCHAR', 'bool', 'column_name', 'company_events', 'competitive_signals', 'data_type', 'date32', 'date32[day]', 'date64', 'document_extractions', 'documents', 'double', 'float', 'float32', 'float64', "format = 'PARQUET'", 'global_events', 'iceberg', 'int16', 'int32', 'int64', 'int8', 'is_nullable', 'large_string', 'large_utf8', 'localhost', 'macro_impacts', 'manifest_list', 'market_bars', 'market_quotes', 'model_performance', 'operation', 'parent_id', 'pnl_daily', 'positions_daily', 'row', 'snapshot_id', 'stonks', 'string', 'summary', 'timestamp', 'trade_fills', 'trade_orders', 'trade_signals', 'trend_projections', 'tz=', 'utf8']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/aggregation/worker.py
# hypothesis_version: 6.151.14
[-1.0, -0.15, 0.0, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 1.0, 20.0, 3600.0, 'catalyst_type', 'company', 'company_id', 'competitive_enabled', 'computed_at', 'confidence', 'contributing_factors', 'document_id', 'estimated_duration', 'event_id', 'event_published_at', 'id', 'impact_direction', 'impact_score', 'key_facts', 'low', 'macro_enabled', 'macro_impact_score', 'mixed', 'negative', 'neutral', 'novelty_score', 'opposing', 'other', 'pattern_confidence', 'positive', 'published_at', 'risks', 'sentiment', 'severity', 'short_term', 'signal_direction', 'signal_strength', 'source_credibility', 'source_document_id', 'source_ticker', 'supporting', 'target_ticker', 'ticker', 'true']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/symbol_registry/app.py
# hypothesis_version: 6.151.14
[0.5, 201, 365, 404, 409, 503, '/companies', '/health', '/watchlists', 'Already a member', 'Company not found', 'Database unavailable', 'SELECT 1', '^[A-Z]{1,10}$', 'access_policy', 'added', 'base_url', 'brand', 'broker', 'config', 'endpoint', 'filings_api', 'http', 'https', 'internal', 'market_api', 'news_api', 'ok', 'public', 'restricted', 'source_type', 'status', 'symbol_registry', 'ticker', 'url', 'web_scrape']
+4
View File
@@ -0,0 +1,4 @@
# file: /home/celes/sources/celesrenata/stonks-oracle/services/aggregation/interpolation.py
# hypothesis_version: 6.151.14
[-0.693, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.7, 0.75, 0.85, 1.0, 1.2, 168.0, 'AE', 'AU', 'BR', 'CA', 'CN', 'Consumer Staples', 'DE', 'EU', 'Energy', 'Financials', 'GB', 'Health Care', 'IN', 'Industrials', 'JP', 'KR', 'Materials', 'RU', 'Real Estate', 'SA', 'US', 'Utilities', 'commodity_shock', 'copper', 'corn', 'cost_increase', 'crude_oil', 'currency_impact', 'demand_shift', 'geopolitical_risk', 'inferred', 'interpolation', 'large_cap', 'lithium', 'micro_cap', 'mid_cap', 'mixed', 'natural_gas', 'negative', 'neutral', 'positive', 'regulatory_pressure', 'semiconductors', 'short_term', 'small_cap', 'steel', 'supply_disruption', 'trade_barrier', 'wheat']
Binary file not shown.
-1
View File
@@ -11,7 +11,6 @@ from __future__ import annotations
import json import json
import logging import logging
import uuid
from dataclasses import dataclass, field from dataclasses import dataclass, field
from datetime import datetime, timezone from datetime import datetime, timezone
+1 -3
View File
@@ -16,7 +16,7 @@ from datetime import datetime, timezone
import asyncpg import asyncpg
from services.shared.schemas import TrendDirection, TrendSummary from services.shared.schemas import TrendSummary
logger = logging.getLogger("projection") logger = logging.getLogger("projection")
@@ -169,10 +169,8 @@ def project_macro_decay(
# Decay factor: ratio of future impact to current impact # Decay factor: ratio of future impact to current impact
if half_life > 0: if half_life > 0:
current_factor = math.pow(2.0, -current_age_days / half_life)
future_factor = math.pow(2.0, -future_age_days / half_life) future_factor = math.pow(2.0, -future_age_days / half_life)
else: else:
current_factor = 0.0
future_factor = 0.0 future_factor = 0.0
severity_w = _SEVERITY_WEIGHT.get(ev.severity, 0.25) severity_w = _SEVERITY_WEIGHT.get(ev.severity, 0.25)
+10 -11
View File
@@ -27,6 +27,12 @@ from services.aggregation.evidence import (
rank_evidence as _rank_evidence_composite, rank_evidence as _rank_evidence_composite,
) )
from services.aggregation.market_context import fetch_market_context from services.aggregation.market_context import fetch_market_context
from services.aggregation.pattern_matcher import find_self_patterns
from services.aggregation.projection import (
MacroEventInfo,
compute_projection,
persist_trend_projection,
)
from services.aggregation.scoring import ( from services.aggregation.scoring import (
ScoringConfig, ScoringConfig,
WeightedSignal, WeightedSignal,
@@ -34,23 +40,16 @@ from services.aggregation.scoring import (
sentiment_to_numeric, sentiment_to_numeric,
weighted_sentiment_average, weighted_sentiment_average,
) )
from services.aggregation.signal_propagation import (
CompetitiveSignalRecord,
build_pattern_weighted_signals,
)
from services.shared.metrics import ( from services.shared.metrics import (
AGGREGATION_CONTRADICTION_SCORE, AGGREGATION_CONTRADICTION_SCORE,
AGGREGATION_DURATION, AGGREGATION_DURATION,
AGGREGATION_SIGNALS_PROCESSED, AGGREGATION_SIGNALS_PROCESSED,
AGGREGATION_WINDOWS_COMPUTED, AGGREGATION_WINDOWS_COMPUTED,
) )
from services.aggregation.pattern_matcher import find_self_patterns
from services.aggregation.projection import (
MacroEventInfo,
TrendProjection,
compute_projection,
persist_trend_projection,
)
from services.aggregation.signal_propagation import (
CompetitiveSignalRecord,
build_pattern_weighted_signals,
)
from services.shared.schemas import TrendDirection, TrendSummary, TrendWindow from services.shared.schemas import TrendDirection, TrendSummary, TrendWindow
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
+6 -8
View File
@@ -16,6 +16,7 @@ import json
import logging import logging
import time as _time import time as _time
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
from dataclasses import asdict
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Any, Optional from typing import Any, Optional
@@ -27,11 +28,16 @@ from pydantic import BaseModel
from starlette.middleware.base import BaseHTTPMiddleware from starlette.middleware.base import BaseHTTPMiddleware
from starlette.responses import Response from starlette.responses import Response
from services.aggregation.pattern_matcher import (
find_cross_company_patterns,
find_self_patterns,
)
from services.extractor.metrics import get_model_performance_summary from services.extractor.metrics import get_model_performance_summary
from services.shared.audit import get_entity_audit_trail, get_order_audit_trail, record_audit_event from services.shared.audit import get_entity_audit_trail, get_order_audit_trail, record_audit_event
from services.shared.config import load_config from services.shared.config import load_config
from services.shared.db import get_pg_pool from services.shared.db import get_pg_pool
from services.shared.logging import new_trace_id, set_trace_context, setup_logging from services.shared.logging import new_trace_id, set_trace_context, setup_logging
from services.shared.schemas import MAJOR_DECISION_CATALYSTS
logger = logging.getLogger("query_api") logger = logging.getLogger("query_api")
@@ -2092,14 +2098,6 @@ async def toggle_competitive_layer(body: CompetitiveToggleBody):
# (Requirements 10.1, 10.2, 10.3, 10.4, 11.4, 11.6) # (Requirements 10.1, 10.2, 10.3, 10.4, 11.4, 11.6)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
from dataclasses import asdict
from services.aggregation.pattern_matcher import (
find_cross_company_patterns,
find_self_patterns,
)
from services.shared.schemas import MAJOR_DECISION_CATALYSTS
def _pattern_to_dict(p) -> dict[str, Any]: def _pattern_to_dict(p) -> dict[str, Any]:
"""Convert a HistoricalPattern dataclass to a JSON-safe dict.""" """Convert a HistoricalPattern dataclass to a JSON-safe dict."""
+1 -2
View File
@@ -461,10 +461,9 @@ async def classify_global_event(
model_name = ollama_client._config.model model_name = ollama_client._config.model
# Persist prompt to MinIO # Persist prompt to MinIO
prompt_ref = None
if minio_client: if minio_client:
try: try:
prompt_ref = _upload_classification_prompt( _upload_classification_prompt(
minio_client, document_id, prompts, model_name, timestamp=ts, minio_client, document_id, prompts, model_name, timestamp=ts,
) )
except Exception: except Exception:
+1 -1
View File
@@ -128,8 +128,8 @@ TABLE_SCHEMAS: dict[str, pa.Schema] = {
# These are added after the initial dict definition. # These are added after the initial dict definition.
def _register_worker_schemas() -> None: def _register_worker_schemas() -> None:
from services.lake_publisher.worker import ( from services.lake_publisher.worker import (
COMPETITOR_RELATIONSHIPS_SCHEMA,
COMPETITIVE_SIGNALS_SCHEMA, COMPETITIVE_SIGNALS_SCHEMA,
COMPETITOR_RELATIONSHIPS_SCHEMA,
GLOBAL_EVENTS_SCHEMA, GLOBAL_EVENTS_SCHEMA,
MACRO_IMPACTS_SCHEMA, MACRO_IMPACTS_SCHEMA,
TREND_PROJECTIONS_SCHEMA, TREND_PROJECTIONS_SCHEMA,
+2 -2
View File
@@ -35,6 +35,8 @@ from minio import Minio
from services.lake_publisher.partitions import partition_values from services.lake_publisher.partitions import partition_values
from services.lake_publisher.worker import ( from services.lake_publisher.worker import (
publish_competitive_signal_fact,
publish_competitor_relationship_fact,
publish_document_extraction, publish_document_extraction,
publish_document_extractions_batch, publish_document_extractions_batch,
publish_document_fact, publish_document_fact,
@@ -48,8 +50,6 @@ from services.lake_publisher.worker import (
publish_trade_fill, publish_trade_fill,
publish_trade_order, publish_trade_order,
publish_trend_projection_fact, publish_trend_projection_fact,
publish_competitor_relationship_fact,
publish_competitive_signal_fact,
) )
from services.shared.config import load_config from services.shared.config import load_config
from services.shared.db import get_minio, get_pg_pool, get_redis from services.shared.db import get_minio, get_pg_pool, get_redis
+1 -1
View File
@@ -15,6 +15,7 @@ from datetime import datetime, timezone
import asyncpg import asyncpg
from minio import Minio from minio import Minio
from services.aggregation.projection import TrendProjection
from services.lake_publisher.worker import publish_recommendation_facts from services.lake_publisher.worker import publish_recommendation_facts
from services.recommendation.eligibility import ( from services.recommendation.eligibility import (
EligibilityConfig, EligibilityConfig,
@@ -31,7 +32,6 @@ from services.recommendation.thesis_llm import (
THESIS_PROMPT_VERSION, THESIS_PROMPT_VERSION,
rewrite_thesis_with_llm, rewrite_thesis_with_llm,
) )
from services.aggregation.projection import TrendProjection
from services.shared.config import OllamaConfig from services.shared.config import OllamaConfig
from services.shared.metrics import ( from services.shared.metrics import (
RECOMMENDATION_CONFIDENCE, RECOMMENDATION_CONFIDENCE,
+2 -2
View File
@@ -12,9 +12,9 @@ from pydantic import BaseModel, field_validator
from services.shared.config import load_config from services.shared.config import load_config
from services.shared.db import get_pg_pool from services.shared.db import get_pg_pool
from services.shared.logging import setup_logging from services.shared.logging import setup_logging
from services.symbol_registry.exposure import router as exposure_router
from services.symbol_registry.competitors import router as competitors_router
from services.symbol_registry.competitor_inference import router as inference_router from services.symbol_registry.competitor_inference import router as inference_router
from services.symbol_registry.competitors import router as competitors_router
from services.symbol_registry.exposure import router as exposure_router
config = load_config() config = load_config()
pool: Optional[asyncpg.Pool] = None pool: Optional[asyncpg.Pool] = None