From 40cc67b4c6265c57ecb28df21b07dc07302536b3 Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Sat, 18 Apr 2026 12:07:07 +0300 Subject: [PATCH] fix(run): _should_skip tz check uses isinstance, tolerates mock cfg Existing lifecycle tests mock cfg via MagicMock; the attribute auto-return made `cfg.operating_hours._tz_cache` truthy-but-not-a-tzinfo, crashing datetime.fromtimestamp with TypeError. Guard with isinstance(tz, tzinfo) so mock configs are silently skipped. Co-Authored-By: Claude Sonnet 4.6 --- src/atm/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/atm/main.py b/src/atm/main.py index c129b8b..3c6589c 100644 --- a/src/atm/main.py +++ b/src/atm/main.py @@ -8,7 +8,7 @@ import os import sys import time from dataclasses import dataclass -from datetime import datetime +from datetime import datetime, tzinfo from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Protocol, cast @@ -742,8 +742,8 @@ def _should_skip(now_ts: float, state: LifecycleState, cfg, canary) -> str | Non if oh is None or not oh.enabled: return None tz = getattr(oh, "_tz_cache", None) - if tz is None: - # Enabled but no tz resolved — skip the check rather than crash mid-loop. + if not isinstance(tz, tzinfo): + # Enabled but no tz resolved (or mock cfg in tests) — skip rather than crash. return None now_exchange = datetime.fromtimestamp(now_ts, tz=tz) # weekday() = 0..6 (MON..SUN). Locale-free; strftime('%a') is not.