fix: resolve pylint and type-checking issues

- Fix return type annotation in SetupRedirectMiddleware.dispatch() to use Response instead of RedirectResponse
- Replace broad 'except Exception' with specific exception types (FileNotFoundError, ValueError, OSError, etc.)
- Rename AppConfig.validate() to validate_config() to avoid shadowing BaseModel.validate()
- Fix ValidationResult.errors field to use List[str] with default_factory
- Add pylint disable comments for intentional broad exception catches during shutdown
- Rename lifespan parameter to _application to indicate unused variable
- Update all callers to use new validate_config() method name
This commit is contained in:
2025-12-13 20:29:07 +01:00
parent 63742bb369
commit 3cb644add4
5 changed files with 37 additions and 23 deletions

View File

@@ -11,7 +11,7 @@ from typing import Callable
from fastapi import Request
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.responses import RedirectResponse
from starlette.responses import RedirectResponse, Response
from starlette.types import ASGIApp
from src.server.services.auth_service import auth_service
@@ -91,11 +91,11 @@ class SetupRedirectMiddleware(BaseHTTPMiddleware):
config = config_service.load_config()
# Validate the loaded config
validation = config.validate()
validation = config.validate_config()
if not validation.valid:
return True
except Exception:
except (FileNotFoundError, ValueError, OSError, AttributeError):
# If we can't load or validate config, setup is needed
return True
@@ -103,7 +103,7 @@ class SetupRedirectMiddleware(BaseHTTPMiddleware):
async def dispatch(
self, request: Request, call_next: Callable
) -> RedirectResponse:
) -> Response:
"""Process the request and redirect to setup if needed.
Args: