Skip to content
Myr

Relax `HeaderTypes` type alias definition (#2317)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Relax `HeaderTypes` type alias definition This replaces `Dict[..., ...]` with `Mapping[..., ...]` in the union definition for `HeaderTypes`. Closes #2314. * Update _models.py

authored by Will Frey · committed by GitHub · parent a754e71 · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Tom Christie <tom@tomchristie.com>

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:httpx/_models.py+2 added-2 removed
1 unmodified line
2import email.message3import json as jsonlib4import typing5import urllib.request6from collections.abc import MutableMapping6from collections.abc import Mapping, MutableMapping7from http.cookiejar import Cookie, CookieJar89from ._content import ByteStream, UnattachedStream, encode_request, encode_response10from ._decoders import (
53 unmodified lines
64 if headers is None:65 self._list = [] # type: typing.List[typing.Tuple[bytes, bytes, bytes]]66 elif isinstance(headers, Headers):67 self._list = list(headers._list)68 elif isinstance(headers, dict):68 elif isinstance(headers, Mapping):69 self._list = [70 (71 normalize_header_key(k, lower=False, encoding=encoding),72 normalize_header_key(k, lower=True, encoding=encoding),
1131 unmodified lines
modified:httpx/_types.py+2 added-2 removed
41 unmodified lines
42]4344HeaderTypes = Union[45 "Headers",46 Dict[str, str],47 Dict[bytes, bytes],46 Mapping[str, str],47 Mapping[bytes, bytes],48 Sequence[Tuple[str, str]],49 Sequence[Tuple[bytes, bytes]],50]51
98 unmodified lines