Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
typing: Apply trivial fixes to adjust edge cases in typing.
Zixuan James Li63e9ae83896d
diff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.pyindex b2091b57f58..67474fea400 100755--- a/tools/lib/provision_inner.py+++ b/tools/lib/provision_inner.py@@ -270,6 +270,7 @@ def main(options: argparse.Namespace) -> int:destroy_leaked_test_databases,)+ assert settings.RABBITMQ_PASSWORD is not Noneif options.is_force or need_to_run_configure_rabbitmq([settings.RABBITMQ_PASSWORD]):run_as_root(["scripts/setup/configure-rabbitmq"])write_new_digest(diff --git a/zerver/actions/realm_linkifiers.py b/zerver/actions/realm_linkifiers.pyindex d208f359124..ea1485fbd8d 100644--- a/zerver/actions/realm_linkifiers.py+++ b/zerver/actions/realm_linkifiers.py@@ -44,6 +44,7 @@ def do_remove_linkifier(if pattern is not None:RealmFilter.objects.get(realm=realm, pattern=pattern).delete()else:+ assert id is not NoneRealmFilter.objects.get(realm=realm, id=id).delete()notify_linkifiers(realm)diff --git a/zerver/actions/streams.py b/zerver/actions/streams.pyindex 912ee8a7afa..28999f6f815 100644--- a/zerver/actions/streams.py+++ b/zerver/actions/streams.py@@ -979,7 +979,8 @@ def do_rename_stream(stream: Stream, new_name: str, user_profile: UserProfile) -).decode(),)- recipient_id = stream.recipient_id+ assert stream.recipient_id is not None+ recipient_id: int = stream.recipient_idmessages = Message.objects.filter(recipient_id=recipient_id).only("id")# Update the display recipient and stream, which are easy singlediff --git a/zerver/context_processors.py b/zerver/context_processors.pyindex 3e0278e4ae8..34776bf9b7c 100644--- a/zerver/context_processors.py+++ b/zerver/context_processors.py@@ -1,4 +1,4 @@-from typing import Any, Dict, Optional+from typing import Any, Dict, Mapping, Optionalfrom urllib.parse import urljoinfrom django.conf import settings@@ -29,7 +29,7 @@ from zproject.backends import (require_email_format_usernames,)-DEFAULT_PAGE_PARAMS = {+DEFAULT_PAGE_PARAMS: Mapping[str, Any] = {"development_environment": settings.DEVELOPMENT,"webpack_public_path": staticfiles_storage.url(settings.WEBPACK_BUNDLES),}diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.pyindex 8e91d067832..c4cd14a9d46 100644--- a/zerver/data_import/rocketchat.py+++ b/zerver/data_import/rocketchat.py@@ -326,9 +326,9 @@ def build_reactions(# For the Unicode emoji codes, we use equivalent of# function 'emoji_name_to_emoji_code' in 'zerver/lib/emoji' here- for reaction in reactions:- emoji_name = reaction["name"]- user_id = reaction["user_id"]+ for reaction_dict in reactions:+ emoji_name = reaction_dict["name"]+ user_id = reaction_dict["user_id"]# Check in realm emojiif emoji_name in realmemoji:emoji_code = realmemoji[emoji_name]diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex f2abbd4a6b2..df8295621c2 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -515,10 +515,10 @@ def public_stream_user_ids(stream: Stream) -> Set[int]:guest_subscriptions = get_active_subscriptions_for_stream_id(stream.id, include_deactivated_users=False).filter(user_profile__role=UserProfile.ROLE_GUEST)- guest_subscriptions = {+ guest_subscriptions_ids = {sub["user_profile_id"] for sub in guest_subscriptions.values("user_profile_id")}- return set(active_non_guest_user_ids(stream.realm_id)) | guest_subscriptions+ return set(active_non_guest_user_ids(stream.realm_id)) | guest_subscriptions_idsdef can_access_stream_user_ids(stream: Stream) -> Set[int]:diff --git a/zerver/models.py b/zerver/models.pyindex b82e31f5d10..e15ffe90bd0 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -2703,6 +2703,7 @@ def get_huddle_recipient(user_profile_ids: Set[int]) -> Recipient:# we hit another cache to get the recipient. We may want to# unify our caching strategy here.huddle = get_huddle(list(user_profile_ids))+ assert huddle.recipient is not Nonereturn huddle.recipientdiff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.pyindex c4bce484ed0..f8e1980237b 100644--- a/zerver/tests/test_auth_backends.py+++ b/zerver/tests/test_auth_backends.py@@ -6724,6 +6724,7 @@ class EmailValidatorTestCase(ZulipTestCase):get_realm_email_validator(realm),)+ assert error is not Noneself.assertIn("containing + are not allowed", error)cordelia_email = cordelia.delivery_emaildiff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.pyindex 206686d601a..649dcde1df8 100644--- a/zerver/tests/test_import_export.py+++ b/zerver/tests/test_import_export.py@@ -905,7 +905,9 @@ class RealmImportExportTest(ExportFile):# test recipientsdef get_recipient_stream(r: Realm) -> Recipient:- return Stream.objects.get(name="Verona", realm=r).recipient+ recipient = Stream.objects.get(name="Verona", realm=r).recipient+ assert recipient is not None+ return recipientdef get_recipient_user(r: Realm) -> Recipient:return UserProfile.objects.get(full_name="Iago", realm=r).recipientdiff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.pyindex 6409af571cd..2f718cf0de6 100644--- a/zerver/tests/test_message_send.py+++ b/zerver/tests/test_message_send.py@@ -1544,6 +1544,7 @@ class StreamMessagesTest(ZulipTestCase):stream = get_stream("Denmark", realm)topic_name = "lunch"recipient = stream.recipient+ assert recipient is not Nonesending_client = make_client(name="test suite")for i in range(num_extra_users):