Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ruff: Fix RSE102 Unnecessary parentheses on raised exception.
Anders Kaseorgda3cf5ea7ad6
diff --git a/confirmation/models.py b/confirmation/models.pyindex 16df5d9ef75..ee2f66e6c0e 100644--- a/confirmation/models.py+++ b/confirmation/models.py@@ -240,10 +240,10 @@ def validate_key(creation_key: Optional[str]) -> Optional["RealmCreationKey"]:try:key_record = RealmCreationKey.objects.get(creation_key=creation_key)except RealmCreationKey.DoesNotExist:- raise RealmCreationKey.InvalidError()+ raise RealmCreationKey.InvalidErrortime_elapsed = timezone_now() - key_record.date_createdif time_elapsed.total_seconds() > settings.REALM_CREATION_LINK_VALIDITY_DAYS * 24 * 3600:- raise RealmCreationKey.InvalidError()+ raise RealmCreationKey.InvalidErrorreturn key_recorddiff --git a/corporate/lib/registration.py b/corporate/lib/registration.pyindex 29ce00f5e57..0390a820fac 100644--- a/corporate/lib/registration.py+++ b/corporate/lib/registration.py@@ -82,7 +82,7 @@ def check_spare_licenses_available_for_adding_new_users(if plan.licenses() < get_seat_count(realm, extra_non_guests_count=extra_non_guests_count, extra_guests_count=extra_guests_count):- raise LicenseLimitError()+ raise LicenseLimitErrordef check_spare_licenses_available_for_registering_new_user(diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 5ed4816f7f5..8a0b3565132 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -636,7 +636,7 @@ def ensure_realm_does_not_have_active_plan(realm: Realm) -> None:"Upgrade of %s failed because of existing active plan.",realm.string_id,)- raise UpgradeWithExistingPlanError()+ raise UpgradeWithExistingPlanError@transaction.atomicdiff --git a/tools/tail-ses b/tools/tail-sesindex 42e9c116e12..05823da8422 100755--- a/tools/tail-ses+++ b/tools/tail-ses@@ -82,7 +82,7 @@ def get_ses_arn(session: boto3.session.Session, args: argparse.Namespace) -> strreturn settings["ComplaintTopic"]elif args.deliveries:return settings["DeliveryTopic"]- raise AssertionError() # Unreachable+ raise AssertionError # Unreachable@contextmanagerdiff --git a/zerver/context_processors.py b/zerver/context_processors.pyindex a822ec1d056..041bcda7d9e 100644--- a/zerver/context_processors.py+++ b/zerver/context_processors.py@@ -71,7 +71,7 @@ def get_realm_from_request(request: HttpRequest) -> Optional[Realm]:def get_valid_realm_from_request(request: HttpRequest) -> Realm:realm = get_realm_from_request(request)if realm is None:- raise InvalidSubdomainError()+ raise InvalidSubdomainErrorreturn realmdiff --git a/zerver/decorator.py b/zerver/decorator.pyindex e53e5e47eb8..7e633f85193 100644--- a/zerver/decorator.py+++ b/zerver/decorator.py@@ -139,7 +139,7 @@ def require_realm_owner(**kwargs: ParamT.kwargs,) -> HttpResponse:if not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorreturn func(request, user_profile, *args, **kwargs)return wrapper@@ -157,7 +157,7 @@ def require_realm_admin(**kwargs: ParamT.kwargs,) -> HttpResponse:if not user_profile.is_realm_admin:- raise OrganizationAdministratorRequiredError()+ raise OrganizationAdministratorRequiredErrorreturn func(request, user_profile, *args, **kwargs)return wrapper@@ -175,7 +175,7 @@ def require_organization_member(**kwargs: ParamT.kwargs,) -> HttpResponse:if user_profile.role > UserProfile.ROLE_MEMBER:- raise OrganizationMemberRequiredError()+ raise OrganizationMemberRequiredErrorreturn func(request, user_profile, *args, **kwargs)return wrapper@@ -257,9 +257,9 @@ def validate_api_key(def validate_account_and_subdomain(request: HttpRequest, user_profile: UserProfile) -> None:if user_profile.realm.deactivated:- raise RealmDeactivatedError()+ raise RealmDeactivatedErrorif not user_profile.is_active:- raise UserDeactivatedError()+ raise UserDeactivatedError# Either the subdomain matches, or we're accessing Tornado from# and to localhost (aka spoofing a request as the user).@@ -281,17 +281,17 @@ def access_user_by_api_key(request: HttpRequest, api_key: str, email: Optional[str] = None) -> UserProfile:if not has_api_key_format(api_key):- raise InvalidAPIKeyFormatError()+ raise InvalidAPIKeyFormatErrortry:user_profile = get_user_profile_by_api_key(api_key)except UserProfile.DoesNotExist:- raise InvalidAPIKeyError()+ raise InvalidAPIKeyErrorif email is not None and email.lower() != user_profile.delivery_email.lower():# This covers the case that the API key is correct, but for a# different user. We may end up wanting to relaxing this# constraint or give a different error message in the future.- raise InvalidAPIKeyError()+ raise InvalidAPIKeyErrorvalidate_account_and_subdomain(request, user_profile)@@ -866,7 +866,7 @@ def authenticated_json_view(**kwargs: ParamT.kwargs,) -> HttpResponse:if not request.user.is_authenticated:- raise UnauthorizedError()+ raise UnauthorizedErroruser_profile = request.userif not skip_rate_limiting:@@ -913,7 +913,7 @@ def internal_notify_view(request: HttpRequest, /, *args: ParamT.args, **kwargs: ParamT.kwargs) -> HttpResponse:if not authenticate_notify(request):- raise AccessDeniedError()+ raise AccessDeniedErrorrequest_notes = RequestNotes.get_notes(request)is_tornado_request = request_notes.tornado_handler_id is not None# These next 2 are not security checks; they are internaldiff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex 28d3e324eca..6a2ea307245 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -647,7 +647,7 @@ def apply_events() -> None:for event in events:if event["type"] == "restart":- raise RestartEventError()+ raise RestartEventErrorif fetch_event_types is not None and event["type"] not in fetch_event_types:# TODO: continuing here is not, most precisely, correct.# In theory, an event of one type, e.g. `realm_user`,diff --git a/zerver/lib/github.py b/zerver/lib/github.pyindex 8ed20b65422..1847f57e3be 100644--- a/zerver/lib/github.py+++ b/zerver/lib/github.py@@ -50,7 +50,7 @@ class InvalidPlatformError(Exception):@cache_with_key(lambda platform: f"download_link:{platform}", timeout=60 * 30)def get_latest_github_release_download_link_for_platform(platform: str) -> str:if platform not in PLATFORM_TO_SETUP_FILE:- raise InvalidPlatformError()+ raise InvalidPlatformErrorlatest_version = get_latest_github_release_version_for_repo("zulip-desktop")if latest_version:diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex fa323545df2..a265cef8585 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -2639,7 +2639,7 @@ def do_convert(logging_message_id,)- raise MarkdownRenderingError()+ raise MarkdownRenderingErrorfinally:# These next three lines are slightly paranoid, since# we always set these right before actually using thediff --git a/zerver/lib/markdown/fenced_code.py b/zerver/lib/markdown/fenced_code.pyindex 910d7eff47f..bfc236ef26e 100644--- a/zerver/lib/markdown/fenced_code.py+++ b/zerver/lib/markdown/fenced_code.py@@ -210,7 +210,7 @@ class ZulipBaseHandler:"""Returns a formatted text.Subclasses should override this method."""- raise NotImplementedError()+ raise NotImplementedErrordef generic_handler(diff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex 1a9bc30fe4c..d98aacdd615 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -766,21 +766,21 @@ def access_web_public_message(# message with the provided ID exists on the server if the client# shouldn't have access to it.if not realm.web_public_streams_enabled():- raise MissingAuthenticationError()+ raise MissingAuthenticationErrortry:message = Message.objects.select_related().get(id=message_id)except Message.DoesNotExist:- raise MissingAuthenticationError()+ raise MissingAuthenticationErrorif not message.is_stream_message():- raise MissingAuthenticationError()+ raise MissingAuthenticationErrorqueryset = get_web_public_streams_queryset(realm)try:stream = queryset.get(id=message.recipient.type_id)except Stream.DoesNotExist:- raise MissingAuthenticationError()+ raise MissingAuthenticationError# These should all have been enforced by the code in# get_web_public_streams_querysetdiff --git a/zerver/lib/rate_limiter.py b/zerver/lib/rate_limiter.pyindex 3b253c727d9..d9e2b0b6961 100644--- a/zerver/lib/rate_limiter.py+++ b/zerver/lib/rate_limiter.py@@ -480,7 +480,7 @@ class RedisRateLimiterBackend(RateLimiterBackend):breakexcept redis.WatchError: # nocoverage # Ideally we'd have a test for this.if count > 10:- raise RateLimiterLockingError()+ raise RateLimiterLockingErrorcount += 1continuediff --git a/zerver/lib/rest.py b/zerver/lib/rest.pyindex f2bf4d5ad12..be4c5e2254a 100644--- a/zerver/lib/rest.py+++ b/zerver/lib/rest.py@@ -192,7 +192,7 @@ def rest_dispatch(request: HttpRequest, /, **kwargs: object) -> HttpResponse:else:# Otherwise, throw an authentication error; our middleware# will generate the appropriate HTTP response.- raise MissingAuthenticationError()+ raise MissingAuthenticationErrorif request.method in ["DELETE", "PATCH", "PUT"]:# process_as_post needs to be the outer decorator, becausediff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex e7934a55964..6043463771f 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -318,7 +318,7 @@ def check_stream_access_for_delete_or_update(if sub is None and stream.invite_only:raise JsonableError(error)- raise OrganizationAdministratorRequiredError()+ raise OrganizationAdministratorRequiredErrordef access_stream_for_delete_or_update(@@ -739,7 +739,7 @@ def list_to_streams(if message_retention_days_not_none:if not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErroruser_profile.realm.ensure_not_on_limited_plan()diff --git a/zerver/lib/upload/base.py b/zerver/lib/upload/base.pyindex d7b9d565c45..5e8e27e4124 100644--- a/zerver/lib/upload/base.py+++ b/zerver/lib/upload/base.py@@ -181,10 +181,10 @@ def resize_emoji(class ZulipUploadBackend:def get_public_upload_root_url(self) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef generate_message_upload_path(self, realm_id: str, uploaded_file_name: str) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef upload_message_file(self,@@ -195,7 +195,7 @@ class ZulipUploadBackend:user_profile: UserProfile,target_realm: Optional[Realm] = None,) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef upload_avatar_image(self,@@ -204,44 +204,44 @@ class ZulipUploadBackend:target_user_profile: UserProfile,content_type: Optional[str] = None,) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef delete_avatar_image(self, user: UserProfile) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef delete_message_image(self, path_id: str) -> bool:- raise NotImplementedError()+ raise NotImplementedErrordef get_avatar_url(self, hash_key: str, medium: bool = False) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef copy_avatar(self, source_profile: UserProfile, target_profile: UserProfile) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef ensure_avatar_image(self, user_profile: UserProfile, is_medium: bool = False) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef upload_realm_icon_image(self, icon_file: IO[bytes], user_profile: UserProfile) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef get_realm_icon_url(self, realm_id: int, version: int) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef upload_realm_logo_image(self, logo_file: IO[bytes], user_profile: UserProfile, night: bool) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef get_realm_logo_url(self, realm_id: int, version: int, night: bool) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef upload_emoji_image(self, emoji_file: IO[bytes], emoji_file_name: str, user_profile: UserProfile) -> bool:- raise NotImplementedError()+ raise NotImplementedErrordef get_emoji_url(self, emoji_file_name: str, realm_id: int, still: bool = False) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef upload_export_tarball(self,@@ -249,13 +249,13 @@ class ZulipUploadBackend:tarball_path: str,percent_callback: Optional[Callable[[Any], None]] = None,) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef delete_export_tarball(self, export_path: str) -> Optional[str]:- raise NotImplementedError()+ raise NotImplementedErrordef get_export_tarball_url(self, realm: Realm, export_path: str) -> str:- raise NotImplementedError()+ raise NotImplementedErrordef realm_avatar_and_logo_path(self, realm: Realm) -> str:return os.path.join(str(realm.id), "realm")diff --git a/zerver/lib/url_preview/parsers/base.py b/zerver/lib/url_preview/parsers/base.pyindex 32d73a0eddf..a70675415d8 100644--- a/zerver/lib/url_preview/parsers/base.py+++ b/zerver/lib/url_preview/parsers/base.py@@ -17,4 +17,4 @@ class BaseParser:self._soup = BeautifulSoup(html_source, "lxml", from_encoding=charset)def extract_data(self) -> UrlEmbedData:- raise NotImplementedError()+ raise NotImplementedErrordiff --git a/zerver/lib/users.py b/zerver/lib/users.pyindex ab533d12222..16d6192d24a 100644--- a/zerver/lib/users.py+++ b/zerver/lib/users.py@@ -145,12 +145,12 @@ def check_bot_creation_policy(user_profile: UserProfile, bot_type: int) -> None:if user_profile.realm.bot_creation_policy == Realm.BOT_CREATION_EVERYONE:returnif user_profile.realm.bot_creation_policy == Realm.BOT_CREATION_ADMINS_ONLY:- raise OrganizationAdministratorRequiredError()+ raise OrganizationAdministratorRequiredErrorif (user_profile.realm.bot_creation_policy == Realm.BOT_CREATION_LIMIT_GENERIC_BOTSand bot_type == UserProfile.DEFAULT_BOT):- raise OrganizationAdministratorRequiredError()+ raise OrganizationAdministratorRequiredErrordef check_valid_bot_type(user_profile: UserProfile, bot_type: int) -> None:@@ -255,7 +255,7 @@ def access_bot_by_id(user_profile: UserProfile, user_id: int) -> UserProfile:# default, because it can be abused to send spam. Requiring an# owner is intended to ensure organizational responsibility# for use of this permission.- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorreturn targetdiff --git a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.pyindex 572dd1bd72d..837da73a76a 100644--- a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py+++ b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py@@ -17,7 +17,7 @@ class Uploader:self.new_path_template = "{realm_id}/emoji/images/{emoji_file_name}"def copy_files(self, src_path: str, dst_path: str) -> None:- raise NotImplementedError()+ raise NotImplementedErrordef ensure_emoji_images(self, realm_id: int, old_filename: str, new_filename: str) -> None:# Copy original image file.diff --git a/zerver/models.py b/zerver/models.pyindex 4de78578c5e..6c892b7407d 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -3733,7 +3733,7 @@ def maybe_get_user_profile_by_api_key(api_key: str) -> Optional[UserProfile]:def get_user_profile_by_api_key(api_key: str) -> UserProfile:user_profile = maybe_get_user_profile_by_api_key(api_key)if user_profile is None:- raise UserProfile.DoesNotExist()+ raise UserProfile.DoesNotExistreturn user_profile@@ -3790,7 +3790,7 @@ def get_active_user(email: str, realm: Realm) -> UserProfile:See get_user docstring for important usage notes."""user_profile = get_user(email, realm)if not user_profile.is_active:- raise UserProfile.DoesNotExist()+ raise UserProfile.DoesNotExistreturn user_profile@@ -3801,7 +3801,7 @@ def get_user_profile_by_id_in_realm(uid: int, realm: Realm) -> UserProfile:def get_active_user_profile_by_id_in_realm(uid: int, realm: Realm) -> UserProfile:user_profile = get_user_profile_by_id_in_realm(uid, realm)if not user_profile.is_active:- raise UserProfile.DoesNotExist()+ raise UserProfile.DoesNotExistreturn user_profile@@ -3839,7 +3839,7 @@ def get_user_by_id_in_realm_including_cross_realm(if is_cross_realm_bot_email(user_profile.delivery_email):return user_profile- raise UserProfile.DoesNotExist()+ raise UserProfile.DoesNotExist@cache_with_key(realm_user_dicts_cache_key, timeout=3600 * 24 * 7)diff --git a/zerver/tests/test_compatibility.py b/zerver/tests/test_compatibility.pyindex 9d555ecfe93..9cb83b907d7 100644--- a/zerver/tests/test_compatibility.py+++ b/zerver/tests/test_compatibility.py@@ -56,7 +56,7 @@ class VersionTest(ZulipTestCase):self.assertIsNone(version_lt(ver1, ver2), msg=msg)self.assertIsNone(version_lt(ver2, ver1), msg=msg)else:- raise AssertionError() # nocoverage+ raise AssertionError # nocoveragemobile_os_data = [case.split(None, 1)@@ -115,7 +115,7 @@ class CompatibilityTest(ZulipTestCase):elif expected == "old":self.assert_json_error(result, "Client is too old")else:- raise AssertionError() # nocoverage+ raise AssertionError # nocoverage@mock.patch("zerver.lib.compatibility.DESKTOP_MINIMUM_VERSION", "5.0.0")@mock.patch("zerver.lib.compatibility.DESKTOP_WARNING_VERSION", "5.2.0")diff --git a/zerver/tests/test_mirror_users.py b/zerver/tests/test_mirror_users.pyindex 8f20fcc377e..55b497e629f 100644--- a/zerver/tests/test_mirror_users.py+++ b/zerver/tests/test_mirror_users.py@@ -170,7 +170,7 @@ class MirroredMessageUsersTest(ZulipTestCase):kwargs["tos_version"] = Nonekwargs["timezone"] = timezone_now()create_user_profile(**kwargs).save()- raise IntegrityError()+ raise IntegrityErrorwith mock.patch("zerver.actions.message_send.create_user", side_effect=create_user) as m:mirror_fred_user = create_mirror_user_if_needed(diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.pyindex a179a36bd79..274d043c0e2 100644--- a/zerver/tests/test_outgoing_webhook_system.py+++ b/zerver/tests/test_outgoing_webhook_system.py@@ -45,7 +45,7 @@ def timeout_error(final_url: Any, **request_kwargs: Any) -> Any:def connection_error(final_url: Any, **request_kwargs: Any) -> Any:- raise requests.exceptions.ConnectionError()+ raise requests.exceptions.ConnectionErrorclass DoRestCallTests(ZulipTestCase):diff --git a/zerver/tests/test_rate_limiter.py b/zerver/tests/test_rate_limiter.pyindex e481a1c6670..60aada3f3b2 100644--- a/zerver/tests/test_rate_limiter.py+++ b/zerver/tests/test_rate_limiter.py@@ -92,7 +92,7 @@ class RateLimiterBackendBase(ZulipTestCase, ABC):"""This depends on the algorithm used in the backend, and should be defined by the test class."""- raise NotImplementedError()+ raise NotImplementedErrordef test_hit_ratelimits(self) -> None:obj = self.create_object("test", [(2, 3)])diff --git a/zerver/views/auth.py b/zerver/views/auth.pyindex a23ef06faba..b875ed1019c 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -479,7 +479,7 @@ def get_email_and_realm_from_jwt_authentication_request() -> Tuple[str, Realm]:realm = get_realm_from_request(request)if realm is None:- raise InvalidSubdomainError()+ raise InvalidSubdomainErrortry:key = settings.JWT_AUTH_KEYS[realm.subdomain]["key"]@@ -922,7 +922,7 @@ def get_api_key_fetch_authenticate_failure(return_data: Dict[str, bool]) -> Jsonif return_data.get("password_reset_needed"):return PasswordResetRequiredError()if return_data.get("invalid_subdomain"):- raise InvalidSubdomainError()+ raise InvalidSubdomainErrorreturn AuthenticationFailedError()@@ -976,7 +976,7 @@ def api_fetch_api_key(realm = get_realm_from_request(request)if realm is None:- raise InvalidSubdomainError()+ raise InvalidSubdomainErrorif not ldap_auth_enabled(realm=realm):# In case we don't authenticate against LDAP, check for a validdiff --git a/zerver/views/development/dev_login.py b/zerver/views/development/dev_login.pyindex 1dc35b8a574..d818f12d30e 100644--- a/zerver/views/development/dev_login.py+++ b/zerver/views/development/dev_login.py@@ -117,20 +117,20 @@ def api_dev_fetch_api_key(request: HttpRequest, username: str = REQ()) -> HttpRevalidate_login_email(username)realm = get_realm_from_request(request)if realm is None:- raise InvalidSubdomainError()+ raise InvalidSubdomainErrorreturn_data: Dict[str, bool] = {}user_profile = authenticate(dev_auth_username=username, realm=realm, return_data=return_data)if return_data.get("inactive_realm"):- raise RealmDeactivatedError()+ raise RealmDeactivatedErrorif return_data.get("inactive_user"):- raise UserDeactivatedError()+ raise UserDeactivatedErrorif return_data.get("invalid_subdomain"):- raise InvalidSubdomainError()+ raise InvalidSubdomainErrorif user_profile is None:# Since we're not actually checking passwords, this condition# is when one's attempting to send an email address that# doesn't have an account, i.e. it's definitely invalid username.- raise AuthenticationFailedError()+ raise AuthenticationFailedErrorassert isinstance(user_profile, UserProfile)do_login(request, user_profile)diff --git a/zerver/views/events_register.py b/zerver/views/events_register.pyindex 8f3eada3367..be516a55cb0 100644--- a/zerver/views/events_register.py+++ b/zerver/views/events_register.py@@ -98,7 +98,7 @@ def events_register_backend(user_profile = Nonerealm = get_valid_realm_from_request(request)if not realm.allow_web_public_streams_access():- raise MissingAuthenticationError()+ raise MissingAuthenticationError# These parameters must be false for anonymous requests.if client_gravatar:diff --git a/zerver/views/invite.py b/zerver/views/invite.pyindex 91fa53ccb2f..78cd106567f 100644--- a/zerver/views/invite.py+++ b/zerver/views/invite.py@@ -34,7 +34,7 @@ def check_if_owner_required(invited_as: int, user_profile: UserProfile) -> None:invited_as == PreregistrationUser.INVITE_AS["REALM_OWNER"]and not user_profile.is_realm_owner):- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredError@require_member_or_admindiff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.pyindex 6d733a330f2..55495666016 100644--- a/zerver/views/message_fetch.py+++ b/zerver/views/message_fetch.py@@ -117,12 +117,12 @@ def get_messages_backend(# that we are not leaking any secure data (private messages and# non-web-public stream messages) via this path.if not realm.allow_web_public_streams_access():- raise MissingAuthenticationError()+ raise MissingAuthenticationErrorif not is_web_public_narrow(narrow):- raise MissingAuthenticationError()+ raise MissingAuthenticationErrorassert narrow is not Noneif not is_spectator_compatible(narrow):- raise MissingAuthenticationError()+ raise MissingAuthenticationError# We use None to indicate unauthenticated requests as it's more# readable than using AnonymousUser, and the lack of Djangodiff --git a/zerver/views/realm.py b/zerver/views/realm.pyindex b6e640299a0..a4fd5ee1e8c 100644--- a/zerver/views/realm.py+++ b/zerver/views/realm.py@@ -155,7 +155,7 @@ def update_realm(raise JsonableError(_("Invalid language '{}'").format(default_language))if authentication_methods is not None:if not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorif True not in list(authentication_methods.values()):raise JsonableError(_("At least one authentication method must be enabled."))if video_chat_provider is not None and video_chat_provider not in {@@ -170,7 +170,7 @@ def update_realm(message_retention_days: Optional[int] = Noneif message_retention_days_raw is not None:if not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorrealm.ensure_not_on_limited_plan()message_retention_days = parse_message_retention_days(message_retention_days_raw, Realm.MESSAGE_RETENTION_SPECIAL_VALUES_MAP@@ -180,15 +180,15 @@ def update_realm(if (invite_to_realm_policy is not None or invite_required is not None) and not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorif (emails_restricted_to_domains is not None or disallow_disposable_email_addresses is not None) and not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorif waiting_period_threshold is not None and not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorif enable_spectator_access:realm.ensure_not_on_limited_plan()@@ -307,7 +307,7 @@ def update_realm(if string_id is not None:if not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorif realm.demo_organization_scheduled_deletion_date is None:raise JsonableError(_("Must be a demo organization."))diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex 80976e6d33b..89f7ad7ccec 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -346,7 +346,7 @@ def update_stream_backend(if message_retention_days is not None:if not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErroruser_profile.realm.ensure_not_on_limited_plan()new_message_retention_days_value = parse_message_retention_days(message_retention_days, Stream.MESSAGE_RETENTION_SPECIAL_VALUES_MAPdiff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex c903205750a..88d6b37b8de 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -79,7 +79,7 @@ def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResif not user_profile.is_active:# TODO: Make this into a user-facing error, not JSON- raise UserDeactivatedError()+ raise UserDeactivatedErrorif user_profile.realm.email_changes_disabled and not user_profile.is_realm_admin:raise JsonableError(_("Email address changes are disabled in this organization."))diff --git a/zerver/views/users.py b/zerver/views/users.pyindex 25090335095..2508a8cc22a 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -117,7 +117,7 @@ def deactivate_user_backend() -> HttpResponse:target = access_user_by_id(user_profile, user_id, for_admin=True)if target.is_realm_owner and not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorif check_last_owner(target):raise JsonableError(_("Cannot deactivate the only organization owner"))if deactivation_notification_comment is not None:@@ -231,9 +231,9 @@ def update_user_backend(## Logic replicated in patch_bot_backend.if UserProfile.ROLE_REALM_OWNER in [role, target.role] and not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorelif not user_profile.is_realm_admin:- raise OrganizationAdministratorRequiredError()+ raise OrganizationAdministratorRequiredErrorif target.role == UserProfile.ROLE_REALM_OWNER and check_last_owner(target):raise JsonableError(@@ -285,14 +285,14 @@ def avatar(# enabled in the organization.realm = get_valid_realm_from_request(request)if not realm.allow_web_public_streams_access():- raise MissingAuthenticationError()+ raise MissingAuthenticationError# We only allow the ID format for accessing a user's avatar# for spectators. This is mainly for defense in depth, since# email_address_visibility should mean spectators only# interact with fake email addresses anyway.if is_email:- raise MissingAuthenticationError()+ raise MissingAuthenticationErrorif settings.RATE_LIMITING:unique_avatar_key = f"{realm.id}/{email_or_id}/{medium}"@@ -367,9 +367,9 @@ def patch_bot_backend(if role is not None and bot.role != role:# Logic duplicated from update_user_backend.if UserProfile.ROLE_REALM_OWNER in [role, bot.role] and not user_profile.is_realm_owner:- raise OrganizationOwnerRequiredError()+ raise OrganizationOwnerRequiredErrorelif not user_profile.is_realm_admin:- raise OrganizationAdministratorRequiredError()+ raise OrganizationAdministratorRequiredErrordo_change_user_role(bot, role, acting_user=user_profile)diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.pyindex 21b810a67de..c0429ade6b2 100644--- a/zerver/webhooks/jira/view.py+++ b/zerver/webhooks/jira/view.py@@ -362,7 +362,7 @@ def api_jira_webhook(return json_success(request)if event is None:- raise AnomalousWebhookPayloadError()+ raise AnomalousWebhookPayloadErrorif event is not None:content_func = JIRA_CONTENT_FUNCTION_MAPPER.get(event)diff --git a/zerver/webhooks/stripe/view.py b/zerver/webhooks/stripe/view.pyindex 7c49a12ba20..9b14e040490 100644--- a/zerver/webhooks/stripe/view.py+++ b/zerver/webhooks/stripe/view.py@@ -98,7 +98,7 @@ def topic_and_body(payload: WildValue) -> Tuple[str, str]:blacklist)if not previous_attributes: # nocoverage- raise SuppressedEventError()+ raise SuppressedEventErrorreturn "".join("\n* "+ attribute.replace("_", " ").capitalize()@@ -119,18 +119,18 @@ def topic_and_body(payload: WildValue) -> Tuple[str, str]:if resource == "account":if event == "updated":if "previous_attributes" not in payload["data"]:- raise SuppressedEventError()+ raise SuppressedEventErrortopic = "account updates"body = update_string()else:# Part of Stripe Connect- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category == "application_fee": # nocoverage# Part of Stripe Connect- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category == "balance": # nocoverage# Not that interesting to most businesses, I think- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category == "charge":if resource == "charge":if not topic: # only in legacy fixtures@@ -160,10 +160,10 @@ def topic_and_body(payload: WildValue) -> Tuple[str, str]:)if category == "checkout_beta": # nocoverage# Not sure what this is- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category == "coupon": # nocoverage# Not something that likely happens programmatically- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category == "customer":if resource == "customer":# Running into the 60 character topic limit.@@ -260,10 +260,10 @@ def topic_and_body(payload: WildValue) -> Tuple[str, str]:)if category.startswith("issuing"): # nocoverage# Not implemented- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category.startswith("order"): # nocoverage# Not implemented- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif category in ["payment_intent","payout",@@ -282,7 +282,7 @@ def topic_and_body(payload: WildValue) -> Tuple[str, str]:# Not implemented. In theory doing something like# body = default_body()# may not be hard for some of these- raise NotImplementedEventTypeError()+ raise NotImplementedEventTypeErrorif body is None:raise UnsupportedWebhookEventTypeError(event_type)diff --git a/zilencer/auth.py b/zilencer/auth.pyindex 2a95a60a12b..34786987f72 100644--- a/zilencer/auth.py+++ b/zilencer/auth.py@@ -78,7 +78,7 @@ def validate_remote_server(raise InvalidZulipServerKeyError(role)if remote_server.deactivated:- raise RemoteServerDeactivatedError()+ raise RemoteServerDeactivatedErrorif get_subdomain(request) != Realm.SUBDOMAIN_FOR_ROOT_DOMAIN:raise JsonableError(_("Invalid subdomain for push notifications bouncer"))diff --git a/zilencer/models.py b/zilencer/models.pyindex 84a5c1121d3..910ac0c287a 100644--- a/zilencer/models.py+++ b/zilencer/models.py@@ -14,7 +14,7 @@ def get_remote_server_by_uuid(uuid: str) -> "RemoteZulipServer":try:return RemoteZulipServer.objects.get(uuid=uuid)except ValidationError:- raise RemoteZulipServer.DoesNotExist()+ raise RemoteZulipServer.DoesNotExistclass RemoteZulipServer(models.Model):