typing: Add none-checks for Recipient objects.

Signed-off-by: Zixuan James Li <359101898@qq.com>
This commit is contained in:
Zixuan James Li 2022-05-30 19:27:38 -04:00 committed by Tim Abbott
parent bb6a934c8d
commit e338ada66c
6 changed files with 8 additions and 0 deletions

View File

@ -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],

View File

@ -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:

View File

@ -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

View File

@ -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,

View File

@ -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))

View File

@ -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(