From ed666c260d79e9858cd3206d87f28ab8abc42dc3 Mon Sep 17 00:00:00 2001 From: Eduardo Rios Date: Tue, 15 Sep 2026 08:18:17 -0300 Subject: [PATCH] fix: satisfy mypy in put_last_data_timestamp after utc=True normalization CI mypy caught what my local environment couldn't (Python 3.14 has no compatible numpy stub for the project's python_version=3.11 mypy target, so mypy couldn't run locally at all): slot_manager.py:353: error: Incompatible types in assignment (expression has type "str", variable has type "Timestamp") slot_manager.py:368: error: Incompatible return value type (got "Timestamp", expected "str | None") Reassigning `last_data_timestamp` from a Timestamp to its strftime() string trips mypy's inference (it fixes an unannotated local's type from its first assignment). Split into a separate `last_data_timestamp_str` for the string form instead of reusing the name. Co-Authored-By: Claude Sonnet 5 --- orchestrator/activities/slot_manager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/orchestrator/activities/slot_manager.py b/orchestrator/activities/slot_manager.py index 38113ea..bbb9ea6 100644 --- a/orchestrator/activities/slot_manager.py +++ b/orchestrator/activities/slot_manager.py @@ -349,11 +349,15 @@ class SlotManager(SientiaMonitoring): # The Redis repository's plain ``json.dumps`` cannot serialize a # ``Timestamp``/``datetime`` directly, so store it as a string - # formatted per ``DATETIME_FORMAT_MS_WITH_TZ`` instead. - last_data_timestamp = last_data_timestamp.strftime(DATETIME_FORMAT_MS_WITH_TZ) + # formatted per ``DATETIME_FORMAT_MS_WITH_TZ`` instead. Kept as a + # separate variable (rather than reassigning ``last_data_timestamp``) + # since it's a different type — mypy infers a local's type from its + # first assignment and flags a same-name reassignment to an + # incompatible type as an error. + last_data_timestamp_str = last_data_timestamp.strftime(DATETIME_FORMAT_MS_WITH_TZ) try: - self.redis_repository.set(key, last_data_timestamp, ttl=60 * 60 * 5) + self.redis_repository.set(key, last_data_timestamp_str, ttl=60 * 60 * 5) except Exception as e: self.send_notification( metadata=metadata, @@ -365,7 +369,7 @@ class SlotManager(SientiaMonitoring): ) raise e - return last_data_timestamp + return last_data_timestamp_str @activity.defn(name='filter_notification_alerts') def filter_notification_alerts(self, input_data: dict[str, Any]) -> dict[str, Any]: