Skip to content

Commit

Permalink
[3.6] add more types to LooseCookies #4205 (#4218)
Browse files Browse the repository at this point in the history
* add more types to LooseCookies #4205

* predefine the Union types for LooseCookies

* add CHANGES fragment
(cherry picked from commit e048934)

Co-authored-by: Adam Bannister <adam.p.bannister@gmail.com>
  • Loading branch information
AtomsForPeace authored and asvetlov committed Oct 18, 2019
1 parent 011ca1f commit 62d6c33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/4218.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add two more types to LooseCookies.
2 changes: 1 addition & 1 deletion aiohttp/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def update_cookies(self,
return

if isinstance(cookies, Mapping):
cookies = cookies.items() # type: ignore
cookies = cookies.items()

for name, cookie in cookies:
if not isinstance(cookie, Morsel):
Expand Down
16 changes: 13 additions & 3 deletions aiohttp/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
_CIMultiDictProxy = CIMultiDictProxy[str]
_MultiDict = MultiDict[str]
_MultiDictProxy = MultiDictProxy[str]
from http.cookies import BaseCookie # noqa
from http.cookies import BaseCookie, Morsel # noqa
else:
_CIMultiDict = CIMultiDict
_CIMultiDictProxy = CIMultiDictProxy
Expand All @@ -43,8 +43,18 @@
_CIMultiDictProxy]
RawHeaders = Tuple[Tuple[bytes, bytes], ...]
StrOrURL = Union[str, URL]
LooseCookies = Union[Iterable[Tuple[str, 'BaseCookie[str]']],
Mapping[str, 'BaseCookie[str]'], 'BaseCookie[str]']

StrBaseCookieTuples = Iterable[Tuple[str, 'BaseCookie[str]']]
StrMorselTuples = Iterable[Tuple[str, 'Morsel[str]']]
StrToBaseCookieMapping = Mapping[str, 'BaseCookie[str]']
StrToMorselMapping = Mapping[str, 'Morsel[Any]']
LooseCookies = Union[
StrBaseCookieTuples,
StrMorselTuples,
StrToBaseCookieMapping,
StrToMorselMapping,
'BaseCookie[str]',
]


if sys.version_info >= (3, 6):
Expand Down

0 comments on commit 62d6c33

Please sign in to comment.