diff --git a/zerver/lib/retention.py b/zerver/lib/retention.py index a3304855e6..f673bf9837 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 = 0 for recipient in recipients: + assert recipient is not None message_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.py index 8989d88a25..66ec605190 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 None get_display_recipient(cordelia_recipient) # Change cordelia's email: diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.py index ee65571612..3c1c3b9d1c 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 None query_ids["scotland_recipient"] = scotland_stream.recipient_id query_ids["hamlet_id"] = hamlet_user.id query_ids["othello_id"] = othello_user.id diff --git a/zerver/tests/test_muting_topics.py b/zerver/tests/test_muting_topics.py index 1e360bd31c..2a407fa069 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 None add_topic_mute( user_profile=user, stream_id=stream.id, diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py index c09e8c60d3..3280e09b89 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 None cond = column("recipient_id", Integer) == recipient.id return query.where(maybe_negate(cond)) diff --git a/zerver/views/message_flags.py b/zerver/views/message_flags.py index 8670baca1e..ebb76b222b 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 None if topic_name: topic_exists = user_message_exists_for_topic(