From 698ea29bc250e9352e9ffb8f055e8afe4c40e5c6 Mon Sep 17 00:00:00 2001 From: zakariaMQ Date: Sun, 3 Mar 2024 15:25:23 +0100 Subject: [PATCH] Added __iadd__ magic method to Cookies class --- httpx/_models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/httpx/_models.py b/httpx/_models.py index 92b393a233..b7efc33726 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -1173,6 +1173,14 @@ def __repr__(self) -> str: ) return f"" + + 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): """