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 TRY201 Use `raise` without specifying exception name.

Anders Kaseorg2d043ffb8368
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 258b8ca8692..120bfe97804 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -1370,7 +1370,7 @@ class BillingSession(ABC):
if isinstance(e, stripe.CardError):
raise StripeCardError("card error", e.user_message)
else: # nocoverage
- raise e
+ raise
assert stripe_invoice.id is not None
return stripe_invoice.id
diff --git a/corporate/views/upgrade.py b/corporate/views/upgrade.py
index a135275536b..9de89bc57df 100644
--- a/corporate/views/upgrade.py
+++ b/corporate/views/upgrade.py
@@ -68,7 +68,7 @@ def upgrade(
license_management,
licenses,
)
- raise e
+ raise
except Exception:
billing_logger.exception("Uncaught exception in billing:", stack_info=True)
error_message = BillingError.CONTACT_SUPPORT.format(email=settings.ZULIP_ADMINISTRATOR)
@@ -118,7 +118,7 @@ def remote_realm_upgrade(
license_management,
licenses,
)
- raise e
+ raise
except Exception: # nocoverage
billing_logger.exception("Uncaught exception in billing:", stack_info=True)
error_message = BillingError.CONTACT_SUPPORT.format(email=settings.ZULIP_ADMINISTRATOR)
@@ -168,7 +168,7 @@ def remote_server_upgrade(
license_management,
licenses,
)
- raise e
+ raise
except Exception: # nocoverage
billing_logger.exception("Uncaught exception in billing:", stack_info=True)
error_message = BillingError.CONTACT_SUPPORT.format(email=settings.ZULIP_ADMINISTRATOR)
diff --git a/zerver/decorator.py b/zerver/decorator.py
index dd385b41213..039e89d0199 100644
--- a/zerver/decorator.py
+++ b/zerver/decorator.py
@@ -412,7 +412,7 @@ def webhook_view(
# the sender's fault, so tell the owner
notify_bot_owner_about_invalid_json(user_profile, webhook_client_name)
- raise err
+ raise
# Store the event types registered for this webhook as an attribute, which can be access
# later conveniently in zerver.lib.test_classes.WebhookTestCase.
@@ -828,7 +828,7 @@ def authenticated_rest_api_view(
return view_func(request, user_profile, *args, **kwargs)
except Exception as err:
if not webhook_client_name:
- raise err
+ raise
if not isinstance(err, JsonableError):
# An unexpected exception of some form -- log it
@@ -840,7 +840,7 @@ def authenticated_rest_api_view(
err.webhook_name = webhook_client_name
log_exception_to_webhook_logger(request, err)
- raise err
+ raise
return _wrapped_func_arguments
diff --git a/zerver/lib/avatar.py b/zerver/lib/avatar.py
index d518cd837fc..3e5bcd83b12 100644
--- a/zerver/lib/avatar.py
+++ b/zerver/lib/avatar.py
@@ -206,9 +206,9 @@ def generate_avatar_jdenticon(input: str, medium: bool) -> bytes:
try:
stdout = subprocess.check_output(command)
return stdout
- except subprocess.CalledProcessError as error: # nocoverage
+ except subprocess.CalledProcessError: # nocoverage
logger.exception("Jdenticon generation failed for user_id: %s", input)
- raise error
+ raise
def generate_and_upload_jdenticon_avatar(
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index 9619dc2789f..8a1a62b8f5e 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -149,7 +149,7 @@ def make_checker(base_model: type[BaseEvent]) -> Callable[[str, dict[str, object
del event["id"]
try:
validate_with_model(event, base_model)
- except Exception as e: # nocoverage
+ except Exception: # nocoverage
print(f"""
FAILURE:
@@ -170,7 +170,7 @@ Here is the event:
""")
PrettyPrinter(indent=4).pprint(event)
- raise e
+ raise
return f
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index 51d39c93c82..1c8c278e790 100644
--- a/zerver/lib/push_notifications.py
+++ b/zerver/lib/push_notifications.py
@@ -1566,7 +1566,7 @@ def send_push_notifications(
if is_test_notification:
# Propagate the exception to the caller to notify the client
# about the error while attempting to send test push notification.
- raise e
+ raise
return
diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py
index 98aa223706c..e3f013338ba 100644
--- a/zerver/lib/send_email.py
+++ b/zerver/lib/send_email.py
@@ -474,9 +474,9 @@ def send_future_email(
assert len(to_emails) == 1
email.address = parseaddr(to_emails[0])[1]
email.save()
- except Exception as e:
+ except Exception:
email.delete()
- raise e
+ raise
def send_email_to_admins(
diff --git a/zerver/management/commands/send_password_reset_email.py b/zerver/management/commands/send_password_reset_email.py
index 1c2bcd19073..1ccd497fd0d 100644
--- a/zerver/management/commands/send_password_reset_email.py
+++ b/zerver/management/commands/send_password_reset_email.py
@@ -45,7 +45,7 @@ class Command(ZulipBaseCommand):
raise CommandError(
"You have to pass -u/--users or -a/--all-users or --entire-server."
)
- raise error
+ raise
if options["only_never_logged_in"]:
users = users.filter(tos_version=-1)
diff --git a/zilencer/auth.py b/zilencer/auth.py
index a0ccad76ead..ab0cf5b6992 100644
--- a/zilencer/auth.py
+++ b/zilencer/auth.py
@@ -95,9 +95,9 @@ def rate_limit_remote_server(
try:
RateLimitedRemoteZulipServer(remote_server, domain=domain).rate_limit_request(request)
- except RateLimitedError as e:
+ except RateLimitedError:
logger.warning("Remote server %s exceeded rate limits on domain %s", remote_server, domain)
- raise e
+ raise
def validate_remote_server(