Skip to content

armgit / zulip

Public Imported from GitHub
0

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.py
index 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.InvalidError
time_elapsed = timezone_now() - key_record.date_created
if time_elapsed.total_seconds() > settings.REALM_CREATION_LINK_VALIDITY_DAYS * 24 * 3600:
- raise RealmCreationKey.InvalidError()
+ raise RealmCreationKey.InvalidError
return key_record
diff --git a/corporate/lib/registration.py b/corporate/lib/registration.py
index 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 LicenseLimitError
def check_spare_licenses_available_for_registering_new_user(
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 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.atomic
diff --git a/tools/tail-ses b/tools/tail-ses
index 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) -> str
return settings["ComplaintTopic"]
elif args.deliveries:
return settings["DeliveryTopic"]
- raise AssertionError() # Unreachable
+ raise AssertionError # Unreachable
@contextmanager
diff --git a/zerver/context_processors.py b/zerver/context_processors.py
index 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 InvalidSubdomainError
return realm
diff --git a/zerver/decorator.py b/zerver/decorator.py
index 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 OrganizationOwnerRequiredError
return 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 OrganizationAdministratorRequiredError
return 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 OrganizationMemberRequiredError
return 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 RealmDeactivatedError
if 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 InvalidAPIKeyFormatError
try:
user_profile = get_user_profile_by_api_key(api_key)
except UserProfile.DoesNotExist:
- raise InvalidAPIKeyError()
+ raise InvalidAPIKeyError
if 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 InvalidAPIKeyError
validate_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 UnauthorizedError
user_profile = request.user
if 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 AccessDeniedError
request_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 internal
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 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 RestartEventError
if 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.py
index 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 InvalidPlatformError
latest_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__.py
index 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 MarkdownRenderingError
finally:
# These next three lines are slightly paranoid, since
# we always set these right before actually using the
diff --git a/zerver/lib/markdown/fenced_code.py b/zerver/lib/markdown/fenced_code.py
index 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 NotImplementedError
def generic_handler(
diff --git a/zerver/lib/message.py b/zerver/lib/message.py
index 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 MissingAuthenticationError
try:
message = Message.objects.select_related().get(id=message_id)
except Message.DoesNotExist:
- raise MissingAuthenticationError()
+ raise MissingAuthenticationError
if not message.is_stream_message():
- raise MissingAuthenticationError()
+ raise MissingAuthenticationError
queryset = 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_queryset
diff --git a/zerver/lib/rate_limiter.py b/zerver/lib/rate_limiter.py
index 3b253c727d9..d9e2b0b6961 100644
--- a/zerver/lib/rate_limiter.py
+++ b/zerver/lib/rate_limiter.py
@@ -480,7 +480,7 @@ class RedisRateLimiterBackend(RateLimiterBackend):
break
except redis.WatchError: # nocoverage # Ideally we'd have a test for this.
if count > 10:
- raise RateLimiterLockingError()
+ raise RateLimiterLockingError
count += 1
continue
diff --git a/zerver/lib/rest.py b/zerver/lib/rest.py
index 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 MissingAuthenticationError
if request.method in ["DELETE", "PATCH", "PUT"]:
# process_as_post needs to be the outer decorator, because
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py
index 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 OrganizationAdministratorRequiredError
def 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 OrganizationOwnerRequiredError
user_profile.realm.ensure_not_on_limited_plan()
diff --git a/zerver/lib/upload/base.py b/zerver/lib/upload/base.py
index 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 NotImplementedError
def generate_message_upload_path(self, realm_id: str, uploaded_file_name: str) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def upload_message_file(
self,
@@ -195,7 +195,7 @@ class ZulipUploadBackend:
user_profile: UserProfile,
target_realm: Optional[Realm] = None,
) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def upload_avatar_image(
self,
@@ -204,44 +204,44 @@ class ZulipUploadBackend:
target_user_profile: UserProfile,
content_type: Optional[str] = None,
) -> None:
- raise NotImplementedError()
+ raise NotImplementedError
def delete_avatar_image(self, user: UserProfile) -> None:
- raise NotImplementedError()
+ raise NotImplementedError
def delete_message_image(self, path_id: str) -> bool:
- raise NotImplementedError()
+ raise NotImplementedError
def get_avatar_url(self, hash_key: str, medium: bool = False) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def copy_avatar(self, source_profile: UserProfile, target_profile: UserProfile) -> None:
- raise NotImplementedError()
+ raise NotImplementedError
def ensure_avatar_image(self, user_profile: UserProfile, is_medium: bool = False) -> None:
- raise NotImplementedError()
+ raise NotImplementedError
def upload_realm_icon_image(self, icon_file: IO[bytes], user_profile: UserProfile) -> None:
- raise NotImplementedError()
+ raise NotImplementedError
def get_realm_icon_url(self, realm_id: int, version: int) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def upload_realm_logo_image(
self, logo_file: IO[bytes], user_profile: UserProfile, night: bool
) -> None:
- raise NotImplementedError()
+ raise NotImplementedError
def get_realm_logo_url(self, realm_id: int, version: int, night: bool) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def upload_emoji_image(
self, emoji_file: IO[bytes], emoji_file_name: str, user_profile: UserProfile
) -> bool:
- raise NotImplementedError()
+ raise NotImplementedError
def get_emoji_url(self, emoji_file_name: str, realm_id: int, still: bool = False) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def upload_export_tarball(
self,
@@ -249,13 +249,13 @@ class ZulipUploadBackend:
tarball_path: str,
percent_callback: Optional[Callable[[Any], None]] = None,
) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def delete_export_tarball(self, export_path: str) -> Optional[str]:
- raise NotImplementedError()
+ raise NotImplementedError
def get_export_tarball_url(self, realm: Realm, export_path: str) -> str:
- raise NotImplementedError()
+ raise NotImplementedError
def 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.py
index 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 NotImplementedError
diff --git a/zerver/lib/users.py b/zerver/lib/users.py
index 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:
return
if user_profile.realm.bot_creation_policy == Realm.BOT_CREATION_ADMINS_ONLY:
- raise OrganizationAdministratorRequiredError()
+ raise OrganizationAdministratorRequiredError
if (
user_profile.realm.bot_creation_policy == Realm.BOT_CREATION_LIMIT_GENERIC_BOTS
and bot_type == UserProfile.DEFAULT_BOT
):
- raise OrganizationAdministratorRequiredError()
+ raise OrganizationAdministratorRequiredError
def 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 OrganizationOwnerRequiredError
return target
diff --git a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py
index 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 NotImplementedError
def 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.py
index 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.DoesNotExist
return 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.DoesNotExist
return 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.DoesNotExist
return 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.py
index 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 # nocoverage
mobile_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.py
index 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"] = None
kwargs["timezone"] = timezone_now()
create_user_profile(**kwargs).save()
- raise IntegrityError()
+ raise IntegrityError
with 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.py
index 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.ConnectionError
class DoRestCallTests(ZulipTestCase):
diff --git a/zerver/tests/test_rate_limiter.py b/zerver/tests/test_rate_limiter.py
index 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 NotImplementedError
def test_hit_ratelimits(self) -> None:
obj = self.create_object("test", [(2, 3)])
diff --git a/zerver/views/auth.py b/zerver/views/auth.py
index 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 InvalidSubdomainError
try:
key = settings.JWT_AUTH_KEYS[realm.subdomain]["key"]
@@ -922,7 +922,7 @@ def get_api_key_fetch_authenticate_failure(return_data: Dict[str, bool]) -> Json
if return_data.get("password_reset_needed"):
return PasswordResetRequiredError()
if return_data.get("invalid_subdomain"):
- raise InvalidSubdomainError()
+ raise InvalidSubdomainError
return AuthenticationFailedError()
@@ -976,7 +976,7 @@ def api_fetch_api_key(
realm = get_realm_from_request(request)
if realm is None:
- raise InvalidSubdomainError()
+ raise InvalidSubdomainError
if not ldap_auth_enabled(realm=realm):
# In case we don't authenticate against LDAP, check for a valid
diff --git a/zerver/views/development/dev_login.py b/zerver/views/development/dev_login.py
index 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()) -> HttpRe
validate_login_email(username)
realm = get_realm_from_request(request)
if realm is None:
- raise InvalidSubdomainError()
+ raise InvalidSubdomainError
return_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 RealmDeactivatedError
if return_data.get("inactive_user"):
- raise UserDeactivatedError()
+ raise UserDeactivatedError
if return_data.get("invalid_subdomain"):
- raise InvalidSubdomainError()
+ raise InvalidSubdomainError
if 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 AuthenticationFailedError
assert isinstance(user_profile, UserProfile)
do_login(request, user_profile)
diff --git a/zerver/views/events_register.py b/zerver/views/events_register.py
index 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 = None
realm = 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.py
index 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_admin
diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py
index 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 MissingAuthenticationError
if not is_web_public_narrow(narrow):
- raise MissingAuthenticationError()
+ raise MissingAuthenticationError
assert narrow is not None
if 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 Django
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 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 OrganizationOwnerRequiredError
if 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] = None
if message_retention_days_raw is not None:
if not user_profile.is_realm_owner:
- raise OrganizationOwnerRequiredError()
+ raise OrganizationOwnerRequiredError
realm.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 OrganizationOwnerRequiredError
if (
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 OrganizationOwnerRequiredError
if waiting_period_threshold is not None and not user_profile.is_realm_owner:
- raise OrganizationOwnerRequiredError()
+ raise OrganizationOwnerRequiredError
if 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 OrganizationOwnerRequiredError
if 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.py
index 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 OrganizationOwnerRequiredError
user_profile.realm.ensure_not_on_limited_plan()
new_message_retention_days_value = parse_message_retention_days(
message_retention_days, Stream.MESSAGE_RETENTION_SPECIAL_VALUES_MAP
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index 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) -> HttpRes
if not user_profile.is_active:
# TODO: Make this into a user-facing error, not JSON
- raise UserDeactivatedError()
+ raise UserDeactivatedError
if 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.py
index 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 OrganizationOwnerRequiredError
if 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 OrganizationOwnerRequiredError
elif not user_profile.is_realm_admin:
- raise OrganizationAdministratorRequiredError()
+ raise OrganizationAdministratorRequiredError
if 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 MissingAuthenticationError
if 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 OrganizationOwnerRequiredError
elif not user_profile.is_realm_admin:
- raise OrganizationAdministratorRequiredError()
+ raise OrganizationAdministratorRequiredError
do_change_user_role(bot, role, acting_user=user_profile)
diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.py
index 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 AnomalousWebhookPayloadError
if 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.py
index 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 SuppressedEventError
return "".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 SuppressedEventError
topic = "account updates"
body = update_string()
else:
# Part of Stripe Connect
- raise NotImplementedEventTypeError()
+ raise NotImplementedEventTypeError
if category == "application_fee": # nocoverage
# Part of Stripe Connect
- raise NotImplementedEventTypeError()
+ raise NotImplementedEventTypeError
if category == "balance": # nocoverage
# Not that interesting to most businesses, I think
- raise NotImplementedEventTypeError()
+ raise NotImplementedEventTypeError
if 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 NotImplementedEventTypeError
if category == "coupon": # nocoverage
# Not something that likely happens programmatically
- raise NotImplementedEventTypeError()
+ raise NotImplementedEventTypeError
if 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 NotImplementedEventTypeError
if category.startswith("order"): # nocoverage
# Not implemented
- raise NotImplementedEventTypeError()
+ raise NotImplementedEventTypeError
if 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 NotImplementedEventTypeError
if body is None:
raise UnsupportedWebhookEventTypeError(event_type)
diff --git a/zilencer/auth.py b/zilencer/auth.py
index 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 RemoteServerDeactivatedError
if 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.py
index 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.DoesNotExist
class RemoteZulipServer(models.Model):