Skip to content

Commit

Permalink
Added __iadd__ magic method to Cookies class
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakariaMQ committed Mar 3, 2024
1 parent 7df47ce commit 698ea29
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,14 @@ def __repr__(self) -> str:
)

return f"<Cookies[{cookies_repr}]>"

def __iadd__(self, other):
if isinstance(other, self.__class__):
self._cookies.update(other._cookies)
else:
raise ValueError("Cannot add a non-Cookies instance.")

return self

class _CookieCompatRequest(urllib.request.Request):
"""
Expand Down

0 comments on commit 698ea29

Please sign in to comment.