1+ from __future__ import annotations
2+
3+ from typing import Any , Literal
4+
15from requests .structures import CaseInsensitiveDict
26
37from ..exceptions import AnymailRequestsAPIError
@@ -103,15 +107,15 @@ def __init__(self, message, defaults, backend, *args, **kwargs):
103107 http_headers ["api-key" ] = backend .api_key
104108 http_headers ["Content-Type" ] = "application/json"
105109
106- super ().__init__ (
110+ super ().__init__ ( # type: ignore[misc]
107111 message , defaults , backend , headers = http_headers , * args , ** kwargs
108112 )
109113
110114 def get_api_endpoint (self ):
111115 return "smtp/email"
112116
113117 def init_payload (self ):
114- self .data = {"headers" : CaseInsensitiveDict ()} # becomes json
118+ self .data = {"headers" : CaseInsensitiveDict [ str ] ()} # becomes json
115119 self .merge_data = {}
116120 self .metadata = {}
117121 self .merge_metadata = {}
@@ -125,8 +129,8 @@ def serialize_data(self):
125129 self .data ["messageVersions" ] = []
126130 for to in to_list :
127131 to_email = to ["email" ]
128- version = {"to" : [to ]}
129- headers = CaseInsensitiveDict ()
132+ version : dict [ str , Any ] = {"to" : [to ]}
133+ headers = CaseInsensitiveDict [ str ] ()
130134 if to_email in self .merge_data :
131135 version ["params" ] = self .merge_data [to_email ]
132136 if to_email in self .merge_metadata :
@@ -158,7 +162,7 @@ def serialize_data(self):
158162
159163 def email_object (self , email ):
160164 """Converts EmailAddress to Brevo API object with workarounds"""
161- use_rfc2047 = False
165+ use_rfc2047 : bool | Literal [ "force" ] = False
162166 # In from/to/cc/bcc, Brevo silently drops the "name" field if it
163167 # contains both non-ASCII chars and a comma (or other special).
164168 # In replyTo, Brevo sends the name as 8-bit (unencoded) utf-8.
0 commit comments