Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #8211/7725f5a2 backport][3.10] Fix type annotations on MultipartWriter.append #8215

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading