From 68128640bfd2dbc398790a70da15617daca43fd1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 12 Jan 2022 19:26:51 -0800 Subject: [PATCH] zulip: Fix principals default for remove_subscriptions. The documented API for DELETE /api/v1/users/me/subscriptions is that principals should be omitted to remove a subscription for the calling user. A call with principals=[] should have a different meaning, but a server bug currently conflates this with a call omitting principals. Avoid relying on this bug. Signed-off-by: Anders Kaseorg --- zulip/zulip/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 86765f2..0b6ac52 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -1383,12 +1383,16 @@ class Client: ) def remove_subscriptions( - self, streams: Iterable[str], principals: Union[Sequence[str], Sequence[int]] = [] + self, + streams: Iterable[str], + principals: Optional[Union[Sequence[str], Sequence[int]]] = None, ) -> Dict[str, Any]: """ See examples/unsubscribe for example usage. """ - request = dict(subscriptions=streams, principals=principals) + request: Dict[str, object] = dict(subscriptions=streams) + if principals is not None: + request["principals"] = principals return self.call_endpoint( url="users/me/subscriptions", method="DELETE",