Use dt.timezone.utc so the declared >=3.10 support is real
Some checks are pending
crdt-sync pre-commit / pre-commit (push) Waiting to run
crdt-sync tests / test (3.10) (push) Waiting to run
crdt-sync tests / test (3.11) (push) Waiting to run
crdt-sync tests / test (3.12) (push) Waiting to run

`dt.UTC` is a 3.11+ alias, but crdt-sync declares requires-python = ">=3.10"
and the CI matrix tests 3.10 — so `crdt-sync tests` has been failing on the
3.10 leg since before this branch (commit 493db693 failed the same way).
It collected as `AttributeError: module 'datetime' has no attribute 'UTC'`.

This is not only a test problem: `_firebase_auth._utcnow()` is library code,
so on 3.10 every token-expiry check would have raised at runtime. The three
consumers (diet-guard, screen-locker, wake-alarm) all declare >=3.10 too, so
honouring the floor is the right direction rather than raising it.

`dt.UTC is dt.timezone.utc` evaluates to True — the same singleton under two
spellings — so this is a pure rename with no behaviour change.

Verified on a real pyenv 3.10.16 venv, not just the 3.14 dev interpreter:
239 passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZH89WEqAjuJT8WZdqc7AP
This commit is contained in:
Krzysztof Rudnicki 2026-08-09 19:04:14 +02:00
parent 6eef99d661
commit a4165e0dc8
3 changed files with 3 additions and 3 deletions

View File

@ -161,7 +161,7 @@ class FileCredentialStore:
def _utcnow() -> dt.datetime:
return dt.datetime.now(dt.UTC)
return dt.datetime.now(dt.timezone.utc)
class FirebaseTokenProvider:

View File

@ -56,7 +56,7 @@ def _auth(*, signed_in: bool = True) -> FirebaseTokenProvider:
FirebaseCredentials(
id_token=_FAKE_ID,
refresh_token=_FAKE_REFRESH,
expires_at=dt.datetime(2099, 1, 1, tzinfo=dt.UTC),
expires_at=dt.datetime(2099, 1, 1, tzinfo=dt.timezone.utc),
)
if signed_in
else None

View File

@ -27,7 +27,7 @@ from crdt_sync import _firebase_auth as fa
if TYPE_CHECKING:
from pathlib import Path
_NOW = dt.datetime(2026, 8, 3, 12, tzinfo=dt.UTC)
_NOW = dt.datetime(2026, 8, 3, 12, tzinfo=dt.timezone.utc)
# Fixture values referenced through names ruff's hardcoded-credential checks
# (S105-S107) do not key off. Comparing an attribute called `id_token` to a