From 3115b125de234c96a5cd509594f60f72241f2379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 11 Aug 2019 22:33:42 +0300 Subject: [PATCH 1/3] Type hint istr keys allowed in LooseHeaders So one can use e.g. {hdrs.SOMETHING: ...} as headers. --- aiohttp/typedefs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aiohttp/typedefs.py b/aiohttp/typedefs.py index d7c97a435dd..60b0a4c8156 100644 --- a/aiohttp/typedefs.py +++ b/aiohttp/typedefs.py @@ -12,7 +12,8 @@ Union, ) -from multidict import CIMultiDict, CIMultiDictProxy, MultiDict, MultiDictProxy +from multidict import ( + CIMultiDict, CIMultiDictProxy, MultiDict, MultiDictProxy, istr) from yarl import URL DEFAULT_JSON_ENCODER = json.dumps @@ -33,7 +34,8 @@ Byteish = Union[bytes, bytearray, memoryview] JSONEncoder = Callable[[Any], str] JSONDecoder = Callable[[str], Any] -LooseHeaders = Union[Mapping[str, str], _CIMultiDict, _CIMultiDictProxy] +LooseHeaders = Union[Mapping[Union[str, istr], str], _CIMultiDict, + _CIMultiDictProxy] RawHeaders = Tuple[Tuple[bytes, bytes], ...] StrOrURL = Union[str, URL] LooseCookies = Union[Iterable[Tuple[str, 'BaseCookie[str]']], From 7a9e1a49a59cd3dfaf5d2098a3d7374086cbc441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 14 Aug 2019 16:50:18 +0300 Subject: [PATCH 2/3] isort aiohttp/typedefs imports --- aiohttp/typedefs.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aiohttp/typedefs.py b/aiohttp/typedefs.py index 60b0a4c8156..3c42f6abe30 100644 --- a/aiohttp/typedefs.py +++ b/aiohttp/typedefs.py @@ -13,7 +13,12 @@ ) from multidict import ( - CIMultiDict, CIMultiDictProxy, MultiDict, MultiDictProxy, istr) + CIMultiDict, + CIMultiDictProxy, + MultiDict, + MultiDictProxy, + istr, +) from yarl import URL DEFAULT_JSON_ENCODER = json.dumps From c936b324823f773cc437f3ba70774973884b8e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 14 Aug 2019 16:51:42 +0300 Subject: [PATCH 3/3] Add CHANGES entry for #3976 --- CHANGES/3976.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/3976.bugfix diff --git a/CHANGES/3976.bugfix b/CHANGES/3976.bugfix new file mode 100644 index 00000000000..4e567ff3a11 --- /dev/null +++ b/CHANGES/3976.bugfix @@ -0,0 +1 @@ +Accept istr keys in LooseHeaders type hints.