typing: Add assertions before accessing settings.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-06 00:58:43 -04:00 committed by Tim Abbott
parent a09c9a4063
commit 7c62af0d73
5 changed files with 5 additions and 0 deletions

View File

@ -83,6 +83,7 @@ def init_fakeldap(
mock_ldap = MockLDAP() mock_ldap = MockLDAP()
mock_initialize.return_value = mock_ldap mock_initialize.return_value = mock_ldap
assert settings.FAKE_LDAP_MODE is not None
mock_ldap.directory = directory or generate_dev_ldap_dir( mock_ldap.directory = directory or generate_dev_ldap_dir(
settings.FAKE_LDAP_MODE, settings.FAKE_LDAP_NUM_USERS settings.FAKE_LDAP_MODE, settings.FAKE_LDAP_NUM_USERS
) )

View File

@ -107,6 +107,7 @@ class Command(ZulipBaseCommand):
print("Mobile Push Notification Service registration successfully updated!") print("Mobile Push Notification Service registration successfully updated!")
def _request_push_notification_bouncer_url(self, url: str, params: Dict[str, Any]) -> Response: def _request_push_notification_bouncer_url(self, url: str, params: Dict[str, Any]) -> Response:
assert settings.PUSH_NOTIFICATION_BOUNCER_URL is not None
registration_url = settings.PUSH_NOTIFICATION_BOUNCER_URL + url registration_url = settings.PUSH_NOTIFICATION_BOUNCER_URL + url
session = PushBouncerSession() session = PushBouncerSession()
try: try:

View File

@ -19,6 +19,7 @@ from zerver.models import UserProfile
# since we rearranged the avatars in Zulip 1.6. # since we rearranged the avatars in Zulip 1.6.
def patched_user_avatar_path(user_profile: UserProfile) -> str: def patched_user_avatar_path(user_profile: UserProfile) -> str:
email = user_profile.email email = user_profile.email
assert settings.AVATAR_SALT is not None
user_key = email.lower() + settings.AVATAR_SALT user_key = email.lower() + settings.AVATAR_SALT
return make_safe_digest(user_key, hashlib.sha1) return make_safe_digest(user_key, hashlib.sha1)

View File

@ -220,6 +220,7 @@ class EventsEndpointTest(ZulipTestCase):
self.assertEqual(str(context.exception), "Access denied") self.assertEqual(str(context.exception), "Access denied")
self.assertEqual(context.exception.http_status_code, 403) self.assertEqual(context.exception.http_status_code, 403)
assert settings.SHARED_SECRET is not None
post_data["secret"] = settings.SHARED_SECRET post_data["secret"] = settings.SHARED_SECRET
req = HostRequestMock(post_data, tornado_handler=dummy_handler) req = HostRequestMock(post_data, tornado_handler=dummy_handler)
req.META["REMOTE_ADDR"] = "127.0.0.1" req.META["REMOTE_ADDR"] = "127.0.0.1"

View File

@ -131,6 +131,7 @@ class ExportFile(ZulipTestCase):
def setUp(self) -> None: def setUp(self) -> None:
super().setUp() super().setUp()
assert settings.LOCAL_UPLOADS_DIR is not None
self.rm_tree(settings.LOCAL_UPLOADS_DIR) self.rm_tree(settings.LOCAL_UPLOADS_DIR)
# Deleting LOCAL_UPLOADS_DIR results in the test database # Deleting LOCAL_UPLOADS_DIR results in the test database