Skip to content

Commit

Permalink
[PR #8211/7725f5a2 backport][3.10] Fix type annotations on MultipartW…
Browse files Browse the repository at this point in the history
…riter.append (#8215)

**This is a backport of PR #8211 as merged into master
(7725f5a).**

Co-authored-by: Daniel Golding <goldingd89@gmail.com>
  • Loading branch information
patchback[bot] and cakemanny authored Mar 10, 2024
1 parent 0854d33 commit 5fdb5c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES/7741.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Changed the type annotations to allow ``dict`` on :meth:`aiohttp.MultipartWriter.append`,
:meth:`aiohttp.MultipartWriter.append_json` and
:meth:`aiohttp.MultipartWriter.append_form` -- by :user:`cakemanny`
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Damien Nadé
Dan King
Dan Xu
Daniel García
Daniel Golding
Daniel Grossmann-Kavanagh
Daniel Nelson
Danny Song
Expand Down
8 changes: 4 additions & 4 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from urllib.parse import parse_qsl, unquote, urlencode

from multidict import CIMultiDict, CIMultiDictProxy, MultiMapping
from multidict import CIMultiDict, CIMultiDictProxy

from .compression_utils import ZLibCompressor, ZLibDecompressor
from .hdrs import (
Expand Down Expand Up @@ -791,7 +791,7 @@ def _boundary_value(self) -> str:
def boundary(self) -> str:
return self._boundary.decode("ascii")

def append(self, obj: Any, headers: Optional[MultiMapping[str]] = None) -> Payload:
def append(self, obj: Any, headers: Optional[Mapping[str, str]] = None) -> Payload:
if headers is None:
headers = CIMultiDict()

Expand Down Expand Up @@ -839,7 +839,7 @@ def append_payload(self, payload: Payload) -> Payload:
return payload

def append_json(
self, obj: Any, headers: Optional[MultiMapping[str]] = None
self, obj: Any, headers: Optional[Mapping[str, str]] = None
) -> Payload:
"""Helper to append JSON part."""
if headers is None:
Expand All @@ -850,7 +850,7 @@ def append_json(
def append_form(
self,
obj: Union[Sequence[Tuple[str, str]], Mapping[str, str]],
headers: Optional[MultiMapping[str]] = None,
headers: Optional[Mapping[str, str]] = None,
) -> Payload:
"""Helper to append form urlencoded part."""
assert isinstance(obj, (Sequence, Mapping))
Expand Down

0 comments on commit 5fdb5c6

Please sign in to comment.