Confirm support for Django 4.1

Replaces deprecated `django.utils.timezone.utc` with
`datetime.timezone.utc` (available since Python 3.2).
This commit is contained in:
Tim Schilling
2022-08-24 15:24:27 -05:00
committed by GitHub
parent 6b3775a8e9
commit a4f50c4340
25 changed files with 80 additions and 89 deletions

View File

@@ -1,8 +1,6 @@
import json
from base64 import b64decode
from datetime import datetime
from django.utils.timezone import utc
from datetime import datetime, timezone
from .base import AnymailBaseWebhookView
from ..exceptions import AnymailConfigurationError
@@ -128,7 +126,7 @@ class SparkPostTrackingWebhookView(SparkPostBaseWebhookView):
event_type = self.event_types.get(event['type'], EventType.UNKNOWN)
try:
timestamp = datetime.fromtimestamp(int(event['timestamp']), tz=utc)
timestamp = datetime.fromtimestamp(int(event['timestamp']), tz=timezone.utc)
except (KeyError, TypeError, ValueError):
timestamp = None