Remove unused service protocol aliases and use direct service imports

This commit is contained in:
2026-04-17 16:01:27 +02:00
parent 7d16391c6c
commit 6e1e3c4546
4 changed files with 25 additions and 111 deletions

View File

@@ -29,16 +29,6 @@ from app.repositories.protocols import (
ImportLogRepository,
SessionRepository,
)
from app.services.protocols import (
AuthService,
BlocklistService,
ConfigService,
GeoService,
HealthService,
HistoryService,
JailService,
ServerService,
)
from app.utils.constants import SESSION_COOKIE_NAME
from app.utils.runtime_state import RuntimeState
from app.utils.session_cache import InMemorySessionCache, NoOpSessionCache, SessionCache
@@ -240,62 +230,6 @@ async def get_session_cache(app_context: Annotated[ApplicationContext, Depends(g
return app_context.session_cache
async def get_auth_service() -> AuthService:
"""Provide the concrete authentication service implementation."""
from app.services import auth_service # noqa: PLC0415
return cast("AuthService", auth_service)
async def get_jail_service() -> JailService:
"""Provide the concrete jail service implementation."""
from app.services import jail_service # noqa: PLC0415
return cast("JailService", jail_service)
async def get_blocklist_service() -> BlocklistService:
"""Provide the concrete blocklist service implementation."""
from app.services import blocklist_service # noqa: PLC0415
return cast("BlocklistService", blocklist_service)
async def get_config_service() -> ConfigService:
"""Provide the concrete configuration service implementation."""
from app.services import config_service # noqa: PLC0415
return cast("ConfigService", config_service)
async def get_history_service() -> HistoryService:
"""Provide the concrete history service implementation."""
from app.services import history_service # noqa: PLC0415
return cast("HistoryService", history_service)
async def get_geo_service() -> GeoService:
"""Provide the concrete geo service implementation."""
from app.services import geo_service # noqa: PLC0415
return cast("GeoService", geo_service)
async def get_health_service() -> HealthService:
"""Provide the concrete health service implementation."""
from app.services import health_service # noqa: PLC0415
return cast("HealthService", health_service)
async def get_server_service() -> ServerService:
"""Provide the concrete server service implementation."""
from app.services import server_service # noqa: PLC0415
return cast("ServerService", server_service)
async def get_session_repo() -> SessionRepository:
"""Provide the concrete session repository implementation."""
from app.repositories import session_repo # noqa: PLC0415
@@ -357,7 +291,6 @@ async def require_auth(
db: Annotated[aiosqlite.Connection, Depends(get_db)],
settings: Annotated[Settings, Depends(get_settings)],
session_cache: Annotated[SessionCache, Depends(get_session_cache)],
auth_service: Annotated[AuthService, Depends(get_auth_service)],
session_repo: Annotated[SessionRepository, Depends(get_session_repo)],
) -> Session:
"""Validate the session token and return the active session.
@@ -403,6 +336,8 @@ async def require_auth(
if cached is not None:
return cached
from app.services import auth_service # noqa: PLC0415
try:
session = await auth_service.validate_session(
db,
@@ -434,14 +369,6 @@ GeoBatchLookupDep = Annotated[GeoBatchLookup, Depends(get_geo_batch_lookup)]
ServerStatusDep = Annotated[ServerStatus, Depends(get_server_status)]
PendingRecoveryDep = Annotated[PendingRecovery | None, Depends(get_pending_recovery)]
SessionCacheDep = Annotated[SessionCache, Depends(get_session_cache)]
AuthServiceDep = Annotated[AuthService, Depends(get_auth_service)]
JailServiceDep = Annotated[JailService, Depends(get_jail_service)]
BlocklistServiceDep = Annotated[BlocklistService, Depends(get_blocklist_service)]
ConfigServiceDep = Annotated[ConfigService, Depends(get_config_service)]
HistoryServiceDep = Annotated[HistoryService, Depends(get_history_service)]
GeoServiceDep = Annotated[GeoService, Depends(get_geo_service)]
HealthServiceDep = Annotated[HealthService, Depends(get_health_service)]
ServerServiceDep = Annotated[ServerService, Depends(get_server_service)]
SessionRepoDep = Annotated[SessionRepository, Depends(get_session_repo)]
BlocklistRepositoryDep = Annotated[BlocklistRepository, Depends(get_blocklist_repo)]
ImportLogRepositoryDep = Annotated[ImportLogRepository, Depends(get_import_log_repo)]