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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user