Relax HeaderTypes type alias definition (#2317)

* 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>
This commit is contained in:
Will Frey 2022-08-30 07:46:19 -04:00 committed by GitHub
parent a754e71f6f
commit ccd98b1a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,7 @@ import email.message
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
@ -65,7 +65,7 @@ class Headers(typing.MutableMapping[str, str]):
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),

View File

@ -43,8 +43,8 @@ QueryParamTypes = Union[
HeaderTypes = Union[
"Headers",
Dict[str, str],
Dict[bytes, bytes],
Mapping[str, str],
Mapping[bytes, bytes],
Sequence[Tuple[str, str]],
Sequence[Tuple[bytes, bytes]],
]