Skip to content

Commit

Permalink
Avoid using UTC alias added in Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Jun 26, 2024
1 parent 856bf3e commit 6b283a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/dispatch/any.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import pickle
from datetime import UTC, datetime, timedelta
from datetime import datetime, timedelta, timezone
from typing import Any

import google.protobuf.any_pb2
Expand Down Expand Up @@ -108,7 +108,7 @@ def unmarshal_any(any: google.protobuf.any_pb2.Any) -> Any:
return proto.value

elif isinstance(proto, google.protobuf.timestamp_pb2.Timestamp):
return proto.ToDatetime(tzinfo=UTC)
return proto.ToDatetime(tzinfo=timezone.utc)

elif isinstance(proto, google.protobuf.duration_pb2.Duration):
return proto.ToTimedelta()
Expand Down
4 changes: 2 additions & 2 deletions tests/dispatch/test_any.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pickle
from datetime import UTC, datetime, timedelta
from datetime import datetime, timedelta, timezone

from dispatch.any import INT64_MAX, INT64_MIN, marshal_any, unmarshal_any
from dispatch.sdk.v1 import error_pb2 as error_pb
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_unmarshal_bytes():


def test_unmarshal_timestamp():
ts = datetime.fromtimestamp(1719372909.641448, UTC)
ts = datetime.fromtimestamp(1719372909.641448, timezone.utc)
boxed = marshal_any(ts)
assert "type.googleapis.com/google.protobuf.Timestamp" == boxed.type_url
assert ts == unmarshal_any(boxed)
Expand Down

0 comments on commit 6b283a4

Please sign in to comment.