Skip to content

Commit 6b283a4

Browse files
committed
Avoid using UTC alias added in Python 3.11
1 parent 856bf3e commit 6b283a4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/dispatch/any.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import pickle
4-
from datetime import UTC, datetime, timedelta
4+
from datetime import datetime, timedelta, timezone
55
from typing import Any
66

77
import google.protobuf.any_pb2
@@ -108,7 +108,7 @@ def unmarshal_any(any: google.protobuf.any_pb2.Any) -> Any:
108108
return proto.value
109109

110110
elif isinstance(proto, google.protobuf.timestamp_pb2.Timestamp):
111-
return proto.ToDatetime(tzinfo=UTC)
111+
return proto.ToDatetime(tzinfo=timezone.utc)
112112

113113
elif isinstance(proto, google.protobuf.duration_pb2.Duration):
114114
return proto.ToTimedelta()

tests/dispatch/test_any.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pickle
2-
from datetime import UTC, datetime, timedelta
2+
from datetime import datetime, timedelta, timezone
33

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

7171

7272
def test_unmarshal_timestamp():
73-
ts = datetime.fromtimestamp(1719372909.641448, UTC)
73+
ts = datetime.fromtimestamp(1719372909.641448, timezone.utc)
7474
boxed = marshal_any(ts)
7575
assert "type.googleapis.com/google.protobuf.Timestamp" == boxed.type_url
7676
assert ts == unmarshal_any(boxed)

0 commit comments

Comments
 (0)