Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
typing: Add none-checks for Recipient objects.
Zixuan James Lie338ada66c67
diff --git a/zerver/lib/retention.py b/zerver/lib/retention.pyindex a3304855e65..f673bf98374 100644--- a/zerver/lib/retention.py+++ b/zerver/lib/retention.py@@ -420,6 +420,7 @@ def archive_stream_messages(recipients = [stream.recipient for stream in streams]message_count = 0for recipient in recipients:+ assert recipient is not Nonemessage_count += archive_messages_by_recipient(recipient,retention_policy_dict[recipient.type_id],diff --git a/zerver/tests/test_message_dict.py b/zerver/tests/test_message_dict.pyindex 8989d88a25f..66ec605190e 100644--- a/zerver/tests/test_message_dict.py+++ b/zerver/tests/test_message_dict.py@@ -450,6 +450,7 @@ class MessageHydrationTest(ZulipTestCase):cordelia_recipient = cordelia.recipient# Cause the display_recipient to get cached:+ assert cordelia_recipient is not Noneget_display_recipient(cordelia_recipient)# Change cordelia's email:diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.pyindex ee655716124..3c1c3b9d1ca 100644--- a/zerver/tests/test_message_fetch.py+++ b/zerver/tests/test_message_fetch.py@@ -1378,6 +1378,9 @@ class GetOldMessagesTest(ZulipTestCase):query_ids: Dict[str, Union[int, str]] = {}scotland_stream = get_stream("Scotland", hamlet_user.realm)+ assert scotland_stream.recipient_id is not None+ assert hamlet_user.recipient_id is not None+ assert othello_user.recipient_id is not Nonequery_ids["scotland_recipient"] = scotland_stream.recipient_idquery_ids["hamlet_id"] = hamlet_user.idquery_ids["othello_id"] = othello_user.iddiff --git a/zerver/tests/test_muting_topics.py b/zerver/tests/test_muting_topics.pyindex 1e360bd31c4..2a407fa069d 100644--- a/zerver/tests/test_muting_topics.py+++ b/zerver/tests/test_muting_topics.py@@ -118,6 +118,7 @@ class MutedTopicsTests(ZulipTestCase):# trying to mute the topic. To do this, we patch the# topic_is_muted function to always return False when trying# to mute a topic that is already muted.+ assert stream.recipient is not Noneadd_topic_mute(user_profile=user,stream_id=stream.id,diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.pyindex c09e8c60d39..3280e09b896 100644--- a/zerver/views/message_fetch.py+++ b/zerver/views/message_fetch.py@@ -298,6 +298,7 @@ class NarrowBuilder:return query.where(maybe_negate(cond))recipient = stream.recipient+ assert recipient is not Nonecond = column("recipient_id", Integer) == recipient.idreturn query.where(maybe_negate(cond))diff --git a/zerver/views/message_flags.py b/zerver/views/message_flags.pyindex 8670baca1e3..ebb76b222b6 100644--- a/zerver/views/message_flags.py+++ b/zerver/views/message_flags.py@@ -82,6 +82,7 @@ def mark_topic_as_read(topic_name: str = REQ(),) -> HttpResponse:stream, sub = access_stream_by_id(user_profile, stream_id)+ assert stream.recipient_id is not Noneif topic_name:topic_exists = user_message_exists_for_topic(