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,9 +1,8 @@
import json
from datetime import datetime
from datetime import datetime, timezone
from email.parser import BytesParser
from email.policy import default as default_policy
from django.utils.timezone import utc
from .base import AnymailBaseWebhookView
from ..inbound import AnymailInboundMessage
@@ -47,7 +46,7 @@ class SendGridTrackingWebhookView(AnymailBaseWebhookView):
def esp_to_anymail_event(self, esp_event):
event_type = self.event_types.get(esp_event['event'], EventType.UNKNOWN)
try:
timestamp = datetime.fromtimestamp(esp_event['timestamp'], tz=utc)
timestamp = datetime.fromtimestamp(esp_event['timestamp'], tz=timezone.utc)
except (KeyError, ValueError):
timestamp = None