From 9a9e446f3fb237f165327413405757162cba4852 Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Sun, 3 May 2026 15:19:32 +0000 Subject: [PATCH] fix(cron): clean persistence lint issues Keep the cron persistence hardening clean under ruff without changing behavior. Co-authored-by: Cursor --- nanobot/cron/service.py | 18 ++++++++++++------ tests/cron/test_cron_persistence.py | 1 - 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/nanobot/cron/service.py b/nanobot/cron/service.py index c3ccd08a..e5428c11 100644 --- a/nanobot/cron/service.py +++ b/nanobot/cron/service.py @@ -14,7 +14,14 @@ from typing import Any, Callable, Coroutine, Literal from filelock import FileLock from loguru import logger -from nanobot.cron.types import CronJob, CronJobState, CronPayload, CronRunRecord, CronSchedule, CronStore +from nanobot.cron.types import ( + CronJob, + CronJobState, + CronPayload, + CronRunRecord, + CronSchedule, + CronStore, +) def _now_ms() -> int: @@ -387,11 +394,10 @@ class CronService: async def _on_timer(self) -> None: """Handle timer tick - run due jobs.""" - loaded = self._load_store() - # If a hot reload found a corrupt store on disk, ``loaded`` is - # ``None`` but ``self._store`` may still hold the previous, - # known-good in-memory snapshot. Keep using it rather than - # crashing the timer or wiping live jobs. + self._load_store() + # If a hot reload found a corrupt store on disk, ``self._store`` may + # still hold the previous, known-good in-memory snapshot. Keep using + # it rather than crashing the timer or wiping live jobs. if not self._store: self._arm_timer() return diff --git a/tests/cron/test_cron_persistence.py b/tests/cron/test_cron_persistence.py index fb218687..4732f61e 100644 --- a/tests/cron/test_cron_persistence.py +++ b/tests/cron/test_cron_persistence.py @@ -9,7 +9,6 @@ jobs.json + don't silently overwrite corrupt store``. from __future__ import annotations import json -import time from pathlib import Path import pytest