Skip to content

Commit

Permalink
Fix typing errors in older python builds
Browse files Browse the repository at this point in the history
  • Loading branch information
cahna committed Nov 10, 2024
1 parent 73897b7 commit c3b2c2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion anymail/backends/mailtrap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import sys
import warnings
from typing import Any, Literal, NotRequired, TypedDict

if sys.version_info < (3, 11):
from typing_extensions import Any, Literal, NotRequired, TypedDict
else:
from typing import Any, Literal, NotRequired, TypedDict

from ..exceptions import AnymailRequestsAPIError, AnymailWarning
from ..message import AnymailMessage, AnymailRecipientStatus
Expand Down
9 changes: 7 additions & 2 deletions anymail/webhooks/mailtrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import json
import sys
from datetime import datetime, timezone
from typing import Literal, NotRequired, TypedDict

if sys.version_info < (3, 11):
from typing_extensions import Any, Literal, NotRequired, TypedDict, Union
else:
from typing import Any, Literal, NotRequired, TypedDict, Union

from ..signals import AnymailTrackingEvent, EventType, RejectReason, tracking
from .base import AnymailBaseWebhookView
Expand All @@ -24,7 +29,7 @@ class MailtrapEvent(TypedDict):
timestamp: int
event_id: str
category: NotRequired[str]
custom_variables: NotRequired[dict[str, str | int | float | bool]]
custom_variables: NotRequired[dict[str, Union[str, int, float, bool]]]
reason: NotRequired[str]
response: NotRequired[str]
response_code: NotRequired[int]
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dependencies = [
"django>=4.0",
"requests>=2.4.3",
"urllib3>=1.25.0", # requests dependency: fixes RFC 7578 header encoding
"typing_extensions>=4.12", # for older Python compatibility
]

[project.optional-dependencies]
Expand All @@ -74,6 +75,7 @@ brevo = []
mailersend = []
mailgun = []
mailjet = []
mailtrap = []
mandrill = []
postmark = []
resend = ["svix"]
Expand Down

0 comments on commit c3b2c2d

Please sign in to comment.