Skip to content

Commit 32d6fcb

Browse files
committed
api_types: Update Stream and Subscription typeddict fields.
This commit updates the `date_created` and `stream_post_policy` fields present in the Stream typeddict, and the `role` field in the Subscription typeddict. For `date_created`, since servers with ZFL<30 do not include the field, but ZT does add it with a value of None to ensure consistency, the type is changed to `NotRequired[Optional[int]]`. For `stream_post_policy`, the field is only included after Zulip 3.0 / ZFL 1, so it has been changed to a NotRequired field. For `role`, the field has been removed in Zulip 6.0 (ZFL 133), so it has been removed from the Subscriptions typeddict and also from the unsubscribed_streams_fixture.
1 parent 895a7a4 commit 32d6fcb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ def unsubscribed_streams_fixture() -> List[Subscription]:
370370
"stream_post_policy": 0,
371371
"is_web_public": True,
372372
"first_message_id": None,
373-
"role": 1,
374373
}
375374
)
376375
return deepcopy(unsubscribed_streams)

zulipterminal/api_types.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,18 @@ class Stream(TypedDict):
216216
name: str
217217
description: str
218218
rendered_description: str
219-
date_created: int # NOTE: new in Zulip 4.0 / ZFL 30
219+
220+
# NOTE: Server data may not contain this field, in which case ZT adds it
221+
# and sets it to None.
222+
date_created: NotRequired[Optional[int]]
223+
220224
invite_only: bool
221225
subscribers: List[int]
222226

223227
is_announcement_only: bool # Deprecated in Zulip 3.0 -> stream_post_policy
224-
stream_post_policy: int # NOTE: new in Zulip 3.0 / ZFL 1
228+
229+
# NOTE: new in Zulip 3.0 / ZFL 1, server versions < 3.0 may not contain this field
230+
stream_post_policy: NotRequired[int]
225231

226232
is_web_public: bool
227233
message_retention_days: Optional[int] # NOTE: new in Zulip 3.0 / ZFL 17
@@ -241,11 +247,11 @@ class Subscription(Stream):
241247

242248
is_muted: bool
243249

244-
role: int # NOTE: new in Zulip 4.0 / ZFL 31
245250
color: str
246251

247252
# Deprecated fields
248253
# in_home_view: bool # Replaced by is_muted in Zulip 2.1; still present in updates
254+
# role: int # Removed in Zulip 6.0 / ZFL 133; not actively used by ZT or Zulip web
249255

250256

251257
###############################################################################

0 commit comments

Comments
 (0)