Skip to content

Commit f9d5601

Browse files
committed
fixed ruff issues and initial mypy issues
1 parent ac0835d commit f9d5601

27 files changed

+856
-671
lines changed

src/api/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/api/config.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,45 @@ class Settings(BaseSettings):
1111
"""Application settings."""
1212

1313
# Redis Configuration
14-
redis_url: str = Field(default="redis://localhost:6379/0", env="REDIS_URL")
14+
redis_url: str = Field(default="redis://localhost:6379/0")
1515

1616
# Celery Configuration
1717
celery_broker_url: str = Field(
18-
default="redis://localhost:6379/0", env="CELERY_BROKER_URL"
18+
default="redis://localhost:6379/0"
1919
)
2020
celery_result_backend: str = Field(
21-
default="redis://localhost:6379/0", env="CELERY_RESULT_BACKEND"
21+
default="redis://localhost:6379/0"
2222
)
2323

2424
# Task Processing Configuration
25-
default_retry_ratio: float = Field(default=0.3, env="DEFAULT_RETRY_RATIO")
26-
max_retries: int = Field(default=3, env="MAX_RETRIES")
27-
max_task_age: int = Field(default=3600, env="MAX_TASK_AGE") # 1 hour
25+
default_retry_ratio: float = Field(default=0.3)
26+
max_retries: int = Field(default=3)
27+
max_task_age: int = Field(default=3600) # 1 hour
2828

2929
# Queue Pressure Thresholds
30-
retry_queue_warning: int = Field(default=1000, env="RETRY_QUEUE_WARNING")
31-
retry_queue_critical: int = Field(default=5000, env="RETRY_QUEUE_CRITICAL")
30+
retry_queue_warning: int = Field(default=1000)
31+
retry_queue_critical: int = Field(default=5000)
3232

3333
# Circuit Breaker Configuration
3434
circuit_failure_threshold: float = Field(
35-
default=0.5, env="CIRCUIT_FAILURE_THRESHOLD"
35+
default=0.5
3636
)
37-
circuit_volume_threshold: int = Field(default=10, env="CIRCUIT_VOLUME_THRESHOLD")
38-
circuit_timeout: int = Field(default=60, env="CIRCUIT_TIMEOUT")
37+
circuit_volume_threshold: int = Field(default=10)
38+
circuit_timeout: int = Field(default=60)
3939

4040
# OpenRouter Configuration
41-
openrouter_api_key: Optional[str] = Field(default=None, env="OPENROUTER_API_KEY")
41+
openrouter_api_key: Optional[str] = Field(default=None)
4242
openrouter_base_url: str = Field(
43-
default="https://openrouter.ai/api/v1", env="OPENROUTER_BASE_URL"
43+
default="https://openrouter.ai/api/v1"
4444
)
4545
openrouter_model: str = Field(
46-
default="meta-llama/llama-3.2-90b-text-preview", env="OPENROUTER_MODEL"
46+
default="meta-llama/llama-3.2-90b-text-preview"
4747
)
48-
openrouter_timeout: int = Field(default=30, env="OPENROUTER_TIMEOUT")
48+
openrouter_timeout: int = Field(default=30)
4949

5050
# Development Configuration
51-
debug: bool = Field(default=False, env="DEBUG")
52-
log_level: str = Field(default="INFO", env="LOG_LEVEL")
51+
debug: bool = Field(default=False)
52+
log_level: str = Field(default="INFO")
5353

5454
# API Configuration
5555
api_title: str = "AsyncTaskFlow API"
@@ -58,9 +58,11 @@ class Settings(BaseSettings):
5858
docs_url: str = "/docs"
5959
redoc_url: str = "/redoc"
6060

61-
class Config:
62-
env_file = ".env"
63-
case_sensitive = False
61+
model_config = {
62+
"env_file": ".env",
63+
"case_sensitive": False,
64+
"env_prefix": "",
65+
}
6466

6567

6668
# Global settings instance

src/api/main.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33

44
import os
55
from contextlib import asynccontextmanager
6+
from typing import AsyncGenerator
67

78
from fastapi import FastAPI
89
from fastapi.middleware.cors import CORSMiddleware
910

1011
from config import settings
11-
from routers import health, tasks, queues, summarize, workers, pdfxtract, redis, openrouter
12+
from routers import (
13+
health,
14+
tasks,
15+
queues,
16+
summarize,
17+
workers,
18+
pdfxtract,
19+
redis,
20+
openrouter,
21+
)
1222
from services import RedisService, TaskService, QueueService, HealthService
1323
import services # Import the module to modify globals
1424

@@ -33,7 +43,7 @@
3343
)
3444

3545

36-
async def initialize_services() -> tuple:
46+
async def initialize_services() -> tuple[RedisService, TaskService, QueueService, HealthService]:
3747
"""Initialize all services and return them."""
3848
print(f"Initializing services in process {os.getpid()}")
3949

@@ -44,7 +54,7 @@ async def initialize_services() -> tuple:
4454
# Test Redis connection
4555
redis_ok = await redis_service.ping()
4656
print(f"Redis connection: {'OK' if redis_ok else 'FAILED'}")
47-
57+
4858
if redis_ok:
4959
# Log connection pool stats
5060
pool_stats = await redis_service.get_pool_stats()
@@ -61,7 +71,7 @@ async def initialize_services() -> tuple:
6171

6272

6373
@asynccontextmanager
64-
async def lifespan(app: FastAPI):
74+
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
6575
"""Application lifespan events."""
6676
# Startup
6777
print("🚀 Starting AsyncTaskFlow API...")
@@ -141,7 +151,7 @@ async def lifespan(app: FastAPI):
141151

142152

143153
@app.get("/")
144-
async def root():
154+
async def root() -> dict[str, str]:
145155
"""Root endpoint."""
146156
return {
147157
"message": "AsyncTaskFlow API",

0 commit comments

Comments
 (0)