From a5e95e206191f77d2970dd2ce1aee0245fa89f4b Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 15 Apr 2026 21:22:56 +0200 Subject: [PATCH] Replace __import__('datetime') antipattern in health_check task --- backend/app/tasks/health_check.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/app/tasks/health_check.py b/backend/app/tasks/health_check.py index fa71a5e..bbb2a12 100644 --- a/backend/app/tasks/health_check.py +++ b/backend/app/tasks/health_check.py @@ -32,9 +32,10 @@ from app.utils.runtime_state import ( ) if TYPE_CHECKING: # pragma: no cover - from app.config import Settings from fastapi import FastAPI + from app.config import Settings + log: structlog.stdlib.BoundLogger = structlog.get_logger() @@ -53,7 +54,7 @@ HEALTH_CHECK_INTERVAL: int = 30 _ACTIVATION_CRASH_WINDOW: int = 60 -async def _run_probe_with_resources(settings: "Settings", runtime_state: RuntimeState) -> None: +async def _run_probe_with_resources(settings: Settings, runtime_state: RuntimeState) -> None: """Probe fail2ban and cache the result on the runtime state. Args: @@ -162,9 +163,7 @@ def register(app: FastAPI) -> None: id="health_check", replace_existing=True, # Fire immediately on startup too, so the UI isn't dark for 30 s. - next_run_time=__import__("datetime").datetime.now( - tz=__import__("datetime").timezone.utc - ), + next_run_time=datetime.datetime.now(tz=datetime.UTC), ) log.info( "health_check_scheduled",