Skip to content

Commit

Permalink
Fix issues related to type hinting.
Browse files Browse the repository at this point in the history
  • Loading branch information
YPCrumble committed Aug 23, 2024
1 parent ebc2e88 commit a31f631
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion anymail/backends/sendgrid.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import uuid
import warnings
from collections.abc import Mapping
from email.utils import quote as rfc822_quote

from requests.structures import CaseInsensitiveDict

from ..exceptions import AnymailConfigurationError, AnymailWarning
from ..message import AnymailRecipientStatus
from ..utils import BASIC_NUMERIC_TYPES, Mapping, get_anymail_setting, update_deep
from ..utils import BASIC_NUMERIC_TYPES, get_anymail_setting, update_deep
from .base_requests import AnymailRequestsBackend, RequestsPayload


Expand Down
5 changes: 3 additions & 2 deletions anymail/backends/unisender_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ def __init__(
http_headers["Content-Type"] = "application/json"
http_headers["Accept"] = "application/json"
http_headers["X-API-KEY"] = backend.api_key
kwargs["headers"] = http_headers
super().__init__(
message, defaults, backend, headers=http_headers, *args, **kwargs
message, defaults, backend, *args, **kwargs
)

def get_api_endpoint(self) -> str:
Expand Down Expand Up @@ -297,7 +298,7 @@ def set_send_at(self, send_at: datetime | str) -> None:
# "Date and time in the format “YYYY-MM-DD hh:mm:ss” in the UTC time zone."
# If send_at is a datetime, it's guaranteed to be aware, but maybe not UTC.
# Convert to UTC, then strip tzinfo to avoid isoformat "+00:00" at end.
send_at_utc = send_at.astimezone(timezone.utc).replace(tzinfo=None)
send_at_utc = send_at.astimezone(timezone.utc).replace(tzinfo=None) # type:ignore[union-attr]
send_at_formatted = send_at_utc.isoformat(sep=" ", timespec="seconds")
assert len(send_at_formatted) == 19
except (AttributeError, TypeError):
Expand Down
2 changes: 1 addition & 1 deletion anymail/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AnymailAPIError(AnymailError):
"""Exception for unsuccessful response from ESP's API."""


class AnymailRequestsAPIError(AnymailAPIError, HTTPError):
class AnymailRequestsAPIError(AnymailAPIError, HTTPError): # type: ignore[misc]
"""Exception for unsuccessful response from a requests API."""

def __init__(self, *args, **kwargs):
Expand Down
4 changes: 3 additions & 1 deletion anymail/webhooks/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import typing
import warnings

from django.dispatch import Signal
from django.http import HttpResponse
from django.utils.crypto import constant_time_compare
from django.utils.decorators import method_decorator
Expand Down Expand Up @@ -30,7 +32,7 @@ def __init__(self, **kwargs):
# Subclass implementation:

# Where to send events: either ..signals.inbound or ..signals.tracking
signal = None
signal: typing.Optional[Signal] = None

def validate_request(self, request):
"""Check validity of webhook post, or raise AnymailWebhookValidationFailure.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sparkpost_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SparkPostBackendMockAPITestCase(RequestsBackendMockAPITestCase):
def setUp(self):
super().setUp()
# Simple message useful for many tests
self.message = mail.EmailMultiAlternatives(
self.message = AnymailMessage(
"Subject", "Text Body", "[email protected]", ["[email protected]"]
)

Expand Down

0 comments on commit a31f631

Please sign in to comment.