Skip to content

Commit 6a21003

Browse files
author
raold
committed
fix: Comprehensive linting and formatting cleanup
- Fixed 678 linting errors automatically with ruff - Applied black formatting to 50 files - Fixed critical undefined names and missing imports - Added missing type annotations and imports - Fixed indentation issues in context_managers.py - Added sklearn import for cosine_similarity - Resolved TypeVar and ParamSpec imports in decorators - Added missing Observable and Priority classes Remaining issues are mostly style improvements (type hints, deprecations) that don't affect functionality
1 parent dc67d8d commit 6a21003

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1702
-1765
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@
119119
"Bash(cmd.exe /c start http://localhost:8001/docs)",
120120
"Bash(pg_isready:*)",
121121
"Bash(./start_postgres_only.sh:*)",
122-
"Bash(git config:*)"
122+
"Bash(git config:*)",
123+
"Bash(cd:*)",
124+
"Bash(cd:*)",
125+
"Bash(cd:*)",
126+
"Bash(cd:*)",
127+
"Bash(cd:*)",
128+
"Bash(cd:*)",
129+
"Bash(cd:*)",
130+
"Bash(cd:*)"
123131
],
124132
"deny": []
125133
}

app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
__version__ = "4.0.0"
77
__author__ = "raold"
88
__email__ = "dro@lynchburgsmiles.com"
9-
__description__ = "AI-powered second brain with Cipher memory integration"
9+
__description__ = "AI-powered second brain with Cipher memory integration"

app/app.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
No circular imports, no bullshit, just clean code that works.
66
"""
77

8-
import os
98
from contextlib import asynccontextmanager
10-
from datetime import datetime
11-
from pathlib import Path
129

13-
from fastapi import FastAPI, HTTPException, Depends
10+
from fastapi import FastAPI
1411
from fastapi.middleware.cors import CORSMiddleware
15-
from pydantic import BaseModel
1612

1713
# Version info
1814
__version__ = "4.0.0"
@@ -27,9 +23,9 @@ async def lifespan(app: FastAPI):
2723
"""Handle application startup and shutdown."""
2824
# Startup
2925
print(f"🚀 Starting Second Brain v{__version__}")
30-
26+
3127
yield
32-
28+
3329
# Shutdown
3430
print("👋 Shutting down Second Brain")
3531

@@ -65,12 +61,13 @@ def include_routers():
6561
try:
6662
# Setup dependencies first
6763
setup_dependencies()
68-
64+
6965
# V2 API routes - the ONLY implementation we use
7066
from app.routes.v2_api import router
67+
7168
app.include_router(router, prefix="")
7269
print("✅ V2 API routes included")
73-
70+
7471
except Exception as e:
7572
print(f"⚠️ Error including routers: {e}")
7673
# Continue anyway - app will work with basic endpoints
@@ -88,22 +85,19 @@ async def root():
8885
"message": "Welcome to Second Brain API v2",
8986
"version": __version__,
9087
"docs": "/docs",
91-
"health": "/api/v2/health"
88+
"health": "/api/v2/health",
9289
}
9390

9491

9592
# Error handling
9693
@app.exception_handler(Exception)
9794
async def general_exception_handler(request, exc):
9895
"""Handle all uncaught exceptions."""
99-
return {
100-
"error": "Internal server error",
101-
"message": str(exc),
102-
"type": type(exc).__name__
103-
}
96+
return {"error": "Internal server error", "message": str(exc), "type": type(exc).__name__}
10497

10598

10699
if __name__ == "__main__":
107100
# For testing only
108101
import uvicorn
109-
uvicorn.run(app, host="0.0.0.0", port=8000)
102+
103+
uvicorn.run(app, host="0.0.0.0", port=8000)

app/config.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Uses the centralized environment manager for consistent configuration.
44
"""
55

6-
from app.core.env_manager import get_env_manager, Environment
6+
from app.core.env_manager import Environment, get_env_manager
77

88
# Get environment manager instance
99
env = get_env_manager()
@@ -14,49 +14,51 @@ class Config:
1414
Application configuration using environment manager.
1515
All environment variables are accessed through the centralized manager.
1616
"""
17-
17+
1818
# Environment
1919
ENVIRONMENT: Environment = env.environment
2020
IS_PRODUCTION: bool = env.is_production()
2121
IS_DEVELOPMENT: bool = env.is_development()
2222
IS_TEST: bool = env.is_test()
23-
23+
2424
# Database Configuration
2525
DATABASE_URL: str = env.get_database_url()
26-
26+
2727
# PostgreSQL Configuration (individual components)
2828
POSTGRES_USER: str = env.get("POSTGRES_USER", "postgres")
2929
POSTGRES_PASSWORD: str = env.get("POSTGRES_PASSWORD", "postgres")
3030
POSTGRES_HOST: str = env.get("POSTGRES_HOST", "localhost")
3131
POSTGRES_PORT: str = env.get("POSTGRES_PORT", "5432")
3232
POSTGRES_DB: str = env.get("POSTGRES_DB", "secondbrain")
33-
33+
3434
# Redis removed - using PostgreSQL for everything
35-
35+
3636
# OpenAI Configuration
3737
OPENAI_API_KEY: str = env.get("OPENAI_API_KEY", "")
3838
OPENAI_EMBEDDING_MODEL: str = env.get("OPENAI_EMBEDDING_MODEL", "text-embedding-3-small")
3939
OPENAI_CHAT_MODEL: str = env.get("OPENAI_CHAT_MODEL", "gpt-4")
40-
40+
4141
# Anthropic Configuration (Optional)
4242
ANTHROPIC_API_KEY: str = env.get("ANTHROPIC_API_KEY", "")
43-
43+
4444
# Container Security (Single User)
4545
CONTAINER_API_KEY: str = env.get("CONTAINER_API_KEY", "")
4646
# JWT removed - not needed for single user containers
47-
47+
4848
# API Configuration
4949
API_TOKENS: list = env.get_list("API_TOKENS", [])
50-
50+
5151
# Application Configuration
5252
HOST: str = env.get("HOST", "127.0.0.1")
5353
PORT: int = env.get_int("PORT", 8000)
5454
DEBUG: bool = env.get_bool("DEBUG", False)
5555
LOG_LEVEL: str = env.get("LOG_LEVEL", "INFO")
56-
56+
5757
# CORS Configuration
58-
CORS_ORIGINS: list = env.get_list("CORS_ORIGINS", ["http://localhost:3000", "http://localhost:8000"])
59-
58+
CORS_ORIGINS: list = env.get_list(
59+
"CORS_ORIGINS", ["http://localhost:3000", "http://localhost:8000"]
60+
)
61+
6062
# Feature Flags
6163
# NO MOCKS - PostgreSQL ONLY
6264
USE_MOCK_DATABASE: bool = False
@@ -65,46 +67,46 @@ class Config:
6567
FEATURE_ATTACHMENTS_ENABLED: bool = env.get_bool("FEATURE_ATTACHMENTS_ENABLED", True)
6668
ENABLE_TELEMETRY: bool = env.get_bool("ENABLE_TELEMETRY", False)
6769
ENABLE_ANALYTICS: bool = env.get_bool("ENABLE_ANALYTICS", False)
68-
70+
6971
# AI Model Configuration
7072
VECTOR_DIMENSION: int = env.get_int("VECTOR_DIMENSION", 1536)
7173
BATCH_SIZE: int = env.get_int("BATCH_SIZE", 100)
7274
SIMILARITY_THRESHOLD: float = env.get_float("SIMILARITY_THRESHOLD", 0.7)
73-
75+
7476
# Monitoring Configuration
7577
OTEL_EXPORTER_OTLP_ENDPOINT: str = env.get("OTEL_EXPORTER_OTLP_ENDPOINT", "")
7678
OTEL_SERVICE_NAME: str = env.get("OTEL_SERVICE_NAME", "second-brain")
7779
SENTRY_DSN: str = env.get("SENTRY_DSN", "")
78-
80+
7981
# Development Configuration
8082
ENABLE_HOT_RELOAD: bool = env.get_bool("ENABLE_HOT_RELOAD", IS_DEVELOPMENT)
8183
ENABLE_DEBUG_TOOLBAR: bool = env.get_bool("ENABLE_DEBUG_TOOLBAR", False)
82-
84+
8385
@classmethod
8486
def validate(cls) -> list:
8587
"""
8688
Validate configuration for production readiness.
87-
89+
8890
Returns:
8991
List of validation issues (empty if valid)
9092
"""
9193
return env.validate_production_ready()
92-
94+
9395
@classmethod
9496
def get_summary(cls) -> dict:
9597
"""
9698
Get configuration summary for logging.
97-
99+
98100
Returns:
99101
Dictionary of configuration values (sensitive values masked)
100102
"""
101103
return env.get_config_summary()
102-
104+
103105
@classmethod
104106
def is_ai_enabled(cls) -> bool:
105107
"""Check if AI features are enabled."""
106108
return bool(cls.OPENAI_API_KEY) or cls.USE_MOCK_OPENAI
107-
109+
108110
@classmethod
109111
def is_database_configured(cls) -> bool:
110112
"""Check if database is configured."""
@@ -114,4 +116,4 @@ def is_database_configured(cls) -> bool:
114116
# Convenience function for backward compatibility
115117
def get_config() -> Config:
116118
"""Get configuration instance."""
117-
return Config
119+
return Config

app/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Core application infrastructure
33
"""
44

5-
# Core module - simplified for single-user architecture
5+
# Core module - simplified for single-user architecture

0 commit comments

Comments
 (0)