mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
mypy: Enable strict optional on lib/soft_deactivation.
Tweaked by tabbott to add assert statements, rather than new conditionals.
This commit is contained in:
2
mypy.ini
2
mypy.ini
@@ -312,7 +312,7 @@ strict_optional = True
|
||||
[mypy-zerver.lib.avatar] # str vs Optional[str]
|
||||
strict_optional = True
|
||||
[mypy-zerver.lib.soft_deactivation]
|
||||
strict_optional = False
|
||||
strict_optional = True
|
||||
[mypy-zerver.lib.events] # signup_notifications_stream is Optional, but accessing id property
|
||||
strict_optional = True
|
||||
[mypy-zerver.lib.exceptions] #21: error: Return type of "__reduce_ex__" incompatible with supertype "object"
|
||||
|
||||
@@ -97,6 +97,7 @@ def add_missing_messages(user_profile: UserProfile) -> None:
|
||||
* Create the UserMessage rows.
|
||||
|
||||
"""
|
||||
assert user_profile.last_active_message_id is not None
|
||||
all_stream_subs = list(Subscription.objects.select_related('recipient').filter(
|
||||
user_profile=user_profile,
|
||||
recipient__type=Recipient.STREAM).values('recipient', 'recipient__type_id'))
|
||||
@@ -118,8 +119,9 @@ def add_missing_messages(user_profile: UserProfile) -> None:
|
||||
recipient_ids = []
|
||||
for sub in all_stream_subs:
|
||||
stream_subscription_logs = all_stream_subscription_logs[sub['recipient__type_id']]
|
||||
if (stream_subscription_logs[-1].event_type == 'subscription_deactivated' and
|
||||
stream_subscription_logs[-1].event_last_message_id <= user_profile.last_active_message_id):
|
||||
if stream_subscription_logs[-1].event_type == 'subscription_deactivated':
|
||||
assert stream_subscription_logs[-1].event_last_message_id is not None
|
||||
if stream_subscription_logs[-1].event_last_message_id <= user_profile.last_active_message_id:
|
||||
# We are going to short circuit this iteration as its no use
|
||||
# iterating since user unsubscribed before soft-deactivation
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user