From c8366ac8d31bc95ea39e4cb5dbf086ca69606553 Mon Sep 17 00:00:00 2001 From: Harshil Vora Date: Thu, 9 Oct 2025 04:28:01 -0700 Subject: [PATCH 1/2] api: Add remove_storage() helper to client. Fixes zulip/python-zulip-api#637 --- zulip/zulip/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index c8d6955de..e7a6aeb3d 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -1640,6 +1640,28 @@ def get_storage(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any method="GET", request=request, ) + def remove_storage(self, request: Dict[str, Any]) -> Dict[str, Any]: + """ + Remove entries from the bot's storage. + + Example: + >>> client.update_storage({'storage': {'a': '1', 'b': '2'}}) + >>> client.remove_storage({'keys': ['a']}) + >>> client.get_storage() + {'result': 'success', 'storage': {'b': '2'}, 'msg': ''} + + Keyword args: + keys (List[str]): Keys to remove from storage. + + Returns: + Dict[str, Any]: Standard Zulip API response dict. + """ + return self.call_endpoint( + url="bot_storage", + method="DELETE", + request=request or {}, + ) + def set_typing_status(self, request: Dict[str, Any]) -> Dict[str, Any]: """ From f201a73c945381ba344b7f0817ed4195531b3e0e Mon Sep 17 00:00:00 2001 From: Harshil Vora Date: Thu, 9 Oct 2025 04:57:21 -0700 Subject: [PATCH 2/2] style: format __init__.py via ruff --- zulip/zulip/__init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index e7a6aeb3d..5c137cfd1 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -597,10 +597,7 @@ def error_retry(error_string: str) -> bool: if self.verbose: if not query_state["had_error_retry"]: sys.stdout.write( - "zulip API({}): connection error{} -- retrying.".format( - url.split(API_VERSTRING, 2)[0], - error_string, - ) + f"zulip API({url.split(API_VERSTRING, 2)[0]}): connection error{error_string} -- retrying." ) query_state["had_error_retry"] = True else: @@ -1640,6 +1637,7 @@ def get_storage(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any method="GET", request=request, ) + def remove_storage(self, request: Dict[str, Any]) -> Dict[str, Any]: """ Remove entries from the bot's storage. @@ -1662,7 +1660,6 @@ def remove_storage(self, request: Dict[str, Any]) -> Dict[str, Any]: request=request or {}, ) - def set_typing_status(self, request: Dict[str, Any]) -> Dict[str, Any]: """ Example usage: