Skip to content

Commit

Permalink
Relax HeaderTypes type alias definition (#2317)
Browse files Browse the repository at this point in the history
* Relax `HeaderTypes` type alias definition

This replaces `Dict[..., ...]` with `Mapping[..., ...]` in the union definition for `HeaderTypes`. Closes #2314.

* Update _models.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
  • Loading branch information
willfrey and tomchristie committed Aug 30, 2022
1 parent a754e71 commit ccd98b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json as jsonlib
import typing
import urllib.request
from collections.abc import MutableMapping
from collections.abc import Mapping, MutableMapping
from http.cookiejar import Cookie, CookieJar

from ._content import ByteStream, UnattachedStream, encode_request, encode_response
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(
self._list = [] # type: typing.List[typing.Tuple[bytes, bytes, bytes]]
elif isinstance(headers, Headers):
self._list = list(headers._list)
elif isinstance(headers, dict):
elif isinstance(headers, Mapping):
self._list = [
(
normalize_header_key(k, lower=False, encoding=encoding),
Expand Down
4 changes: 2 additions & 2 deletions httpx/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

HeaderTypes = Union[
"Headers",
Dict[str, str],
Dict[bytes, bytes],
Mapping[str, str],
Mapping[bytes, bytes],
Sequence[Tuple[str, str]],
Sequence[Tuple[bytes, bytes]],
]
Expand Down

0 comments on commit ccd98b1

Please sign in to comment.