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 RUF059 Unpacked variable is never used.

Anders Kaseorgf24a0a6b81b6
diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py
index 0e5637e71de..5c67b3a7623 100644
--- a/analytics/management/commands/populate_analytics_db.py
+++ b/analytics/management/commands/populate_analytics_db.py
@@ -276,16 +276,16 @@ class Command(ZulipBaseCommand):
property=stat.property, end_time=last_end_time, state=FillState.DONE
)
- website, created = Client.objects.get_or_create(name="website")
- old_desktop, created = Client.objects.get_or_create(name="desktop app Linux 0.3.7")
- android, created = Client.objects.get_or_create(name="ZulipAndroid")
- iOS, created = Client.objects.get_or_create(name="ZulipiOS")
- react_native, created = Client.objects.get_or_create(name="ZulipMobile")
- flutter, created = Client.objects.get_or_create(name="ZulipFlutter")
- API, created = Client.objects.get_or_create(name="API: Python")
- irc_mirror, created = Client.objects.get_or_create(name="irc_mirror")
- unused, created = Client.objects.get_or_create(name="unused")
- long_webhook, created = Client.objects.get_or_create(name="ZulipLooooooooooongNameWebhook")
+ website, _created = Client.objects.get_or_create(name="website")
+ old_desktop, _created = Client.objects.get_or_create(name="desktop app Linux 0.3.7")
+ android, _created = Client.objects.get_or_create(name="ZulipAndroid")
+ iOS, _created = Client.objects.get_or_create(name="ZulipiOS")
+ react_native, _created = Client.objects.get_or_create(name="ZulipMobile")
+ flutter, _created = Client.objects.get_or_create(name="ZulipFlutter")
+ API, _created = Client.objects.get_or_create(name="API: Python")
+ irc_mirror, _created = Client.objects.get_or_create(name="irc_mirror")
+ unused, _created = Client.objects.get_or_create(name="unused")
+ long_webhook, _created = Client.objects.get_or_create(name="ZulipLooooooooooongNameWebhook")
stat = COUNT_STATS["messages_sent:client:day"]
user_data = {
diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py
index d910b8337bd..1dddd6f779c 100644
--- a/analytics/tests/test_counts.py
+++ b/analytics/tests/test_counts.py
@@ -988,7 +988,7 @@ class TestCountStats(AnalyticsTestCase):
realm = {"realm": self.second_realm}
stream1, recipient_stream1 = self.create_stream_with_recipient()
- stream2, recipient_stream2 = self.create_stream_with_recipient(**realm)
+ _stream2, recipient_stream2 = self.create_stream_with_recipient(**realm)
# To be included
self.create_message(human1, recipient_stream1)
@@ -1747,7 +1747,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
user1 = self.create_user()
user2 = self.create_user()
- stream, recipient = self.create_stream_with_recipient()
+ stream, _recipient = self.create_stream_with_recipient()
self.subscribe(user1, stream.name)
self.subscribe(user2, stream.name)
diff --git a/analytics/views/stats.py b/analytics/views/stats.py
index 715fb346f49..bb9eb09dbfb 100644
--- a/analytics/views/stats.py
+++ b/analytics/views/stats.py
@@ -182,7 +182,7 @@ def get_chart_data_for_stream(
start: Annotated[datetime | None, BeforeValidator(to_utc_datetime)] = None,
end: Annotated[datetime | None, BeforeValidator(to_utc_datetime)] = None,
) -> HttpResponse:
- stream, ignored_sub = access_stream_by_id(
+ stream, _sub = access_stream_by_id(
user_profile,
stream_id,
require_content_access=False,
diff --git a/confirmation/migrations/0016_realmcreationkey_to_realmcreationstatus.py b/confirmation/migrations/0016_realmcreationkey_to_realmcreationstatus.py
index d18ab2a4696..40911020226 100644
--- a/confirmation/migrations/0016_realmcreationkey_to_realmcreationstatus.py
+++ b/confirmation/migrations/0016_realmcreationkey_to_realmcreationstatus.py
@@ -32,7 +32,7 @@ def migrate_realmcreationkey_to_realmcreationstatus(
ContentType = apps.get_model("contenttypes", "ContentType")
RealmCreationKey = apps.get_model("confirmation", "RealmCreationKey")
RealmCreationStatus = apps.get_model("zerver", "RealmCreationStatus")
- realm_creation_status_content_type, created = ContentType.objects.get_or_create(
+ realm_creation_status_content_type, _created = ContentType.objects.get_or_create(
model="realmcreationstatus", app_label="zerver"
)
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 5217eb188ad..f4934802408 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -4134,12 +4134,12 @@ class RealmBillingSession(BillingSession):
if stripe_customer_id is not None:
# Support requests do not set any stripe billing information.
assert self.support_session is False
- customer, created = Customer.objects.update_or_create(
+ customer, _created = Customer.objects.update_or_create(
realm=self.realm, defaults={"stripe_customer_id": stripe_customer_id}
)
return customer
else:
- customer, created = Customer.objects.update_or_create(
+ customer, _created = Customer.objects.update_or_create(
realm=self.realm, defaults=defaults
)
return customer
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 525e0078e6e..cf292f7a161 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -1624,7 +1624,7 @@ class StripeTest(StripeTestCase):
plan.next_invoice_date = add_months(free_trial_end_date, 10)
plan.save(update_fields=["next_invoice_date"])
invoice_plans_as_needed(add_months(free_trial_end_date, 10))
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=stripe_customer.id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=stripe_customer.id))
invoice_params = {
"amount_due": 5172,
"auto_advance": True,
@@ -1647,7 +1647,9 @@ class StripeTest(StripeTestCase):
plan.next_invoice_date = add_months(free_trial_end_date, 12)
plan.save(update_fields=["next_invoice_date"])
invoice_plans_as_needed(add_months(free_trial_end_date, 12))
- [invoice0, invoice1, invoice2] = iter(stripe.Invoice.list(customer=stripe_customer.id))
+ [invoice0, _invoice1, _invoice2] = iter(
+ stripe.Invoice.list(customer=stripe_customer.id)
+ )
# Check /billing/ has correct information for fixed price customers.
plan.fixed_price = 127
@@ -3589,7 +3591,7 @@ class StripeTest(StripeTestCase):
self.assertEqual(monthly_plan.next_invoice_date, None)
assert customer.stripe_customer_id
- [invoice0, invoice1, invoice2] = iter(
+ [invoice0, invoice1, _invoice2] = iter(
stripe.Invoice.list(customer=customer.stripe_customer_id)
)
@@ -3638,7 +3640,7 @@ class StripeTest(StripeTestCase):
billing_session.update_license_ledger_if_needed(add_months(self.next_month, 1))
invoice_plans_as_needed(add_months(self.next_month, 1))
- [invoice0, invoice1, invoice2, invoice3] = iter(
+ [invoice0, invoice1, _invoice2, _invoice3] = iter(
stripe.Invoice.list(customer=customer.stripe_customer_id)
)
@@ -3661,7 +3663,7 @@ class StripeTest(StripeTestCase):
annual_plan.save(update_fields=["next_invoice_date"])
invoice_plans_as_needed(add_months(self.now, 13))
- [invoice0, invoice1, invoice2, invoice3, invoice4] = iter(
+ [invoice0, invoice1, _invoice2, _invoice3, _invoice4] = iter(
stripe.Invoice.list(customer=customer.stripe_customer_id)
)
@@ -3755,7 +3757,7 @@ class StripeTest(StripeTestCase):
self.assertEqual(annual_plan.invoicing_status, CustomerPlan.INVOICING_STATUS_DONE)
assert customer.stripe_customer_id
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
[invoice_item] = iter(invoice0.lines)
annual_plan_invoice_item_params = {
@@ -3773,7 +3775,7 @@ class StripeTest(StripeTestCase):
invoice_plans_as_needed(add_months(self.now, 13))
- [invoice0, invoice1, invoice2] = iter(
+ [invoice0, _invoice1, _invoice2] = iter(
stripe.Invoice.list(customer=customer.stripe_customer_id)
)
@@ -3864,7 +3866,7 @@ class StripeTest(StripeTestCase):
customer = get_customer_by_realm(user.realm)
assert customer is not None
assert customer.stripe_customer_id
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
[invoice_item1, invoice_item2] = iter(invoice0.lines)
annual_plan_invoice_item_params = {
"amount": 7322 * 5,
@@ -3946,7 +3948,7 @@ class StripeTest(StripeTestCase):
self.assertEqual(annual_plan.next_invoice_date, None)
assert customer.stripe_customer_id
- [invoice0, invoice1, invoice2] = iter(
+ [invoice0, _invoice1, _invoice2] = iter(
stripe.Invoice.list(customer=customer.stripe_customer_id)
)
@@ -6284,7 +6286,7 @@ class InvoiceTest(StripeTestCase):
billing_session.invoice_plan(plan, self.now + timedelta(days=400))
stripe_customer_id = plan.customer.stripe_customer_id
assert stripe_customer_id is not None
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
self.assertIsNotNone(invoice0.status_transitions.finalized_at)
[item0, item1, item2] = iter(invoice0.lines)
line_item_params = {
@@ -6341,7 +6343,7 @@ class InvoiceTest(StripeTestCase):
billing_session.invoice_plan(plan, self.next_year)
stripe_customer_id = plan.customer.stripe_customer_id
assert stripe_customer_id is not None
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
self.assertEqual(invoice0.collection_method, "send_invoice")
[item] = iter(invoice0.lines)
line_item_params = {
@@ -6535,7 +6537,7 @@ class InvoiceTest(StripeTestCase):
self.assertEqual(plan.next_invoice_date, self.next_month + timedelta(days=29))
stripe_customer_id = plan.customer.stripe_customer_id
assert stripe_customer_id is not None
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
self.assertIsNotNone(invoice0.status_transitions.finalized_at)
[item0] = iter(invoice0.lines)
line_item_params = {
@@ -7302,7 +7304,7 @@ class TestRemoteRealmBillingFlow(StripeTestCase, RemoteRealmBillingTestCase):
CustomerPlan.TIER_SELF_HOSTED_BUSINESS
)
self.assertEqual(min_licenses, 25)
- flat_discount, flat_discounted_months = self.billing_session.get_flat_discount_info()
+ _flat_discount, flat_discounted_months = self.billing_session.get_flat_discount_info()
self.assertEqual(flat_discounted_months, 12)
self.assert_in_success_response(
@@ -8994,9 +8996,9 @@ class TestRemoteRealmBillingFlow(StripeTestCase, RemoteRealmBillingTestCase):
self.assertFalse(plan.stale_audit_log_data_email_sent)
assert customer.stripe_customer_id
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
- [invoice_item0, invoice_item1, invoice_item2] = iter(invoice0.lines)
+ [_invoice_item0, invoice_item1, invoice_item2] = iter(invoice0.lines)
invoice_item_params = {
"amount": 16 * 3.5 * 100,
"description": "Zulip Basic - renewal",
@@ -10581,9 +10583,9 @@ class TestRemoteServerBillingFlow(StripeTestCase, RemoteServerTestCase):
self.assertFalse(plan.stale_audit_log_data_email_sent)
assert customer.stripe_customer_id
- [invoice0, invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
+ [invoice0, _invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
- [invoice_item0, invoice_item1, invoice_item2] = iter(invoice0.lines)
+ [_invoice_item0, invoice_item1, invoice_item2] = iter(invoice0.lines)
invoice_item_params = {
"amount": server_user_count * 3.5 * 100,
"description": "Zulip Basic - renewal",
diff --git a/tools/run-dev b/tools/run-dev
index e2fe7b7bf07..44a472024ea 100755
--- a/tools/run-dev
+++ b/tools/run-dev
@@ -326,7 +326,7 @@ async def help_center_middleware(
if request.path.startswith("/help"):
try:
filename = request.match_info["filename"]
- name, ext = os.path.splitext(filename)
+ _name, ext = os.path.splitext(filename)
if not ext:
filename = os.path.join(filename, "index.html")
request.match_info["filename"] = filename
diff --git a/tools/screenshots/generate-integration-docs-screenshot b/tools/screenshots/generate-integration-docs-screenshot
index 89886032950..4e0972b2553 100755
--- a/tools/screenshots/generate-integration-docs-screenshot
+++ b/tools/screenshots/generate-integration-docs-screenshot
@@ -100,7 +100,7 @@ def create_integration_bot(integration: Integration, bot_name: str | None = None
def create_integration_stream(integration: Integration, bot: UserProfile) -> None:
assert isinstance(bot.bot_owner, UserProfile)
realm = bot.bot_owner.realm
- stream, created = create_stream_if_needed(realm, integration.stream_name)
+ stream, _created = create_stream_if_needed(realm, integration.stream_name)
bulk_add_subscriptions(realm, [stream], [bot, bot.bot_owner], acting_user=bot)
diff --git a/tools/tail-ses b/tools/tail-ses
index 645d1d630e0..601c8bb2df0 100755
--- a/tools/tail-ses
+++ b/tools/tail-ses
@@ -90,7 +90,7 @@ def get_ses_arn(session: boto3.session.Session, args: argparse.Namespace) -> str
@contextmanager
def our_sqs_queue(session: boto3.session.Session, ses_topic_arn: str) -> Iterator[tuple[str, str]]:
- (_, _, _, region, account_id, topic_name) = ses_topic_arn.split(":")
+ (_, _, _, region, account_id, _topic_name) = ses_topic_arn.split(":")
sqs: SQSClient = session.client("sqs")
queue_name = "tail-ses-" + secrets.token_hex(10)
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py
index 16eb3f6248a..1e97da84b55 100644
--- a/zerver/actions/message_edit.py
+++ b/zerver/actions/message_edit.py
@@ -1241,7 +1241,6 @@ def do_update_message(
send_event_on_commit(user_profile.realm, event, users_to_be_notified)
resolved_topic_message_id = None
- resolved_topic_message_deleted = False
# We calculate the users for which the resolved-topic notification
# should be marked as unread using the topic visibility policy and
# the `resolved_topic_notice_auto_read_policy` user setting.
@@ -1258,7 +1257,7 @@ def do_update_message(
and not message_edit_request.is_content_edited
and not message_edit_request.is_stream_edited
):
- resolved_topic_message_id, resolved_topic_message_deleted = (
+ resolved_topic_message_id, _resolved_topic_message_deleted = (
maybe_send_resolve_topic_notifications(
user_profile=user_profile,
message_edit_request=message_edit_request,
diff --git a/zerver/lib/alert_words.py b/zerver/lib/alert_words.py
index b955f7cac9f..8d1dedd90ff 100644
--- a/zerver/lib/alert_words.py
+++ b/zerver/lib/alert_words.py
@@ -32,7 +32,7 @@ def get_alert_word_automaton(realm: Realm) -> ahocorasick.Automaton:
for alert_word in alert_words:
alert_word_lower = alert_word.lower()
if alert_word_automaton.exists(alert_word_lower):
- (key, user_ids_for_alert_word) = alert_word_automaton.get(alert_word_lower)
+ (_key, user_ids_for_alert_word) = alert_word_automaton.get(alert_word_lower)
user_ids_for_alert_word.add(user_id)
else:
alert_word_automaton.add_word(alert_word_lower, (alert_word_lower, {user_id}))
diff --git a/zerver/lib/drafts.py b/zerver/lib/drafts.py
index fe03589b16e..09dcbd887cc 100644
--- a/zerver/lib/drafts.py
+++ b/zerver/lib/drafts.py
@@ -63,7 +63,7 @@ def further_validated_draft_dict(
raise JsonableError(_("Topic must not contain null bytes"))
if len(to) != 1:
raise JsonableError(_("Must specify exactly 1 channel ID for channel messages"))
- stream, sub = access_stream_by_id(user_profile, to[0])
+ stream, _sub = access_stream_by_id(user_profile, to[0])
recipient_id = stream.recipient_id
elif draft_dict.type == "private" and len(to) != 0:
to_users = get_user_profiles_by_ids(set(to), user_profile.realm)
diff --git a/zerver/lib/email_mirror_helpers.py b/zerver/lib/email_mirror_helpers.py
index 2ef10f0b1b3..8f60be743b8 100644
--- a/zerver/lib/email_mirror_helpers.py
+++ b/zerver/lib/email_mirror_helpers.py
@@ -50,7 +50,7 @@ def get_email_gateway_message_string_from_address(address: str) -> str:
def get_channel_email_token(stream: Stream, *, creator: UserProfile, sender: UserProfile) -> str:
- channel_email_address, ignored = ChannelEmailAddress.objects.get_or_create(
+ channel_email_address, _created = ChannelEmailAddress.objects.get_or_create(
realm=stream.realm,
channel=stream,
creator=creator,
diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py
index b941ce1a401..a75485dfb2e 100644
--- a/zerver/lib/email_notifications.py
+++ b/zerver/lib/email_notifications.py
@@ -57,7 +57,7 @@ def relative_to_full_url(fragment: lxml.html.HtmlElement, base_url: str) -> None
# 2: We also need to update the title attribute in the narrow links which
# is not possible with `make_links_absolute()`.
for link_info in fragment.iterlinks():
- elem, attrib, link, pos = link_info
+ elem, attrib, link, _pos = link_info
match = re.match(r"/?#narrow/", link)
if match is not None:
link = re.sub(r"^/?#narrow/", base_url + "/#narrow/", link)
diff --git a/zerver/lib/email_validation.py b/zerver/lib/email_validation.py
index 36e0620ebf2..ad068097400 100644
--- a/zerver/lib/email_validation.py
+++ b/zerver/lib/email_validation.py
@@ -72,7 +72,7 @@ def get_realm_email_validator(realm: Realm) -> Callable[[str], None]:
return
while len(domain) > 0:
- subdomain, sep, domain = domain.partition(".")
+ _subdomain, _sep, domain = domain.partition(".")
if domain in allowed_subdomains:
return
@@ -216,5 +216,5 @@ def validate_email_not_already_in_realm(
# Loop through errors, the only key should be our email.
for key, error_info in error_dict.items():
assert key == email
- msg, deactivated = error_info
+ msg, _deactivated = error_info
raise ValidationError(msg)
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index d0dd9ee2dbc..c8da9473514 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -364,7 +364,7 @@ def check_modern_presence(var_name: str, event: dict[str, object], user_id: int)
assert isinstance(event["presences"], dict)
- [(event_presences_key, event_presences_value)] = event["presences"].items()
+ [(event_presences_key, _event_presences_value)] = event["presences"].items()
assert event_presences_key == str(user_id)
diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py
index e3ba7f66d39..bb946d71e63 100644
--- a/zerver/lib/markdown/__init__.py
+++ b/zerver/lib/markdown/__init__.py
@@ -586,7 +586,7 @@ class BacktickInlineProcessor(markdown.inlinepatterns.BacktickInlineProcessor):
# just replace the text to not strip the group because it
# makes it impossible to put leading/trailing whitespace in
# an inline code span.
- el, start, end = ret = super().handleMatch(m, data)
+ el, _start, _end = ret = super().handleMatch(m, data)
if el is not None and m.group(3):
assert isinstance(el, Element)
# upstream's code here is: m.group(3).strip() rather than m.group(3).
@@ -966,7 +966,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
found_url: ResultWithFamily[tuple[str, str | None]],
) -> None:
info = self.get_inlining_information(root, found_url)
- (url, text) = found_url.result
+ (url, _text) = found_url.result
actual_url = self.get_actual_image_url(url)
self.add_a(
info["parent"],
@@ -985,7 +985,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
yt_image: str,
) -> None:
info = self.get_inlining_information(root, found_url)
- (url, text) = found_url.result
+ (url, _text) = found_url.result
yt_id = self.youtube_id(url)
self.add_a(
info["parent"],
diff --git a/zerver/lib/markdown/nested_code_blocks.py b/zerver/lib/markdown/nested_code_blocks.py
index d0e1cfa8276..8f81c7552a2 100644
--- a/zerver/lib/markdown/nested_code_blocks.py
+++ b/zerver/lib/markdown/nested_code_blocks.py
@@ -29,7 +29,7 @@ class NestedCodeBlocksRendererTreeProcessor(markdown.treeprocessors.Treeprocesso
code_tags = walk_tree_with_family(root, self.get_code_tags)
nested_code_blocks = self.get_nested_code_blocks(code_tags)
for block in nested_code_blocks:
- tag, text = block.result
+ _tag, text = block.result
codehilite_block = self.get_codehilite_block(text)
self.replace_element(block.family.grandparent, codehilite_block, block.family.parent)
diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.py
index e692309674a..309e646de60 100644
--- a/zerver/lib/narrow.py
+++ b/zerver/lib/narrow.py
@@ -1151,7 +1151,7 @@ def find_first_unread_anchor(
)
query = query.add_columns(column("flags", Integer))
- query, is_search, is_dm_narrow = add_narrow_conditions(
+ query, _is_search, is_dm_narrow = add_narrow_conditions(
user_profile=user_profile,
inner_msg_id_col=inner_msg_id_col,
query=query,
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index da9793e8b2a..e39a2dc35f4 100644
--- a/zerver/lib/push_notifications.py
+++ b/zerver/lib/push_notifications.py
@@ -1207,7 +1207,7 @@ def get_message_payload_gcm(
assert message.rendered_content is not None
with override_language(user_profile.default_language):
- content, unused = truncate_content(get_mobile_push_content(message.rendered_content))
+ content, _truncated = truncate_content(get_mobile_push_content(message.rendered_content))
data.update(
time=datetime_to_timestamp(message.date_sent),
content=content,
@@ -1225,7 +1225,7 @@ def get_payload_data_to_encrypt(
mentioned_user_group_name: str | None = None,
can_access_sender: bool = True,
) -> dict[str, Any]:
- payload_data_to_encrypt, unused = get_message_payload_gcm(
+ payload_data_to_encrypt, _gcm_options = get_message_payload_gcm(
user_profile,
message,
mentioned_user_group_id,
@@ -1273,7 +1273,7 @@ def get_remove_payload_data_to_encrypt(
user_profile: UserProfile,
message_ids: list[int],
) -> dict[str, Any]:
- payload_data_to_encrypt, unused = get_remove_payload_gcm(
+ payload_data_to_encrypt, _gcm_options = get_remove_payload_gcm(
user_profile, message_ids, for_legacy_clients=False
)
return payload_data_to_encrypt
diff --git a/zerver/lib/rate_limiter.py b/zerver/lib/rate_limiter.py
index 8f411c0dad1..b5f4ee89230 100644
--- a/zerver/lib/rate_limiter.py
+++ b/zerver/lib/rate_limiter.py
@@ -407,7 +407,7 @@ class RedisRateLimiterBackend(RateLimiterBackend):
def is_ratelimited(cls, entity_key: str, rules: list[tuple[int, int]]) -> tuple[bool, float]:
"""Returns a tuple of (rate_limited, time_till_free)"""
assert rules
- list_key, set_key, blocking_key = cls.get_keys(entity_key)
+ list_key, _set_key, blocking_key = cls.get_keys(entity_key)
# Go through the rules from shortest to longest,
# seeing if this user has violated any of them. First
diff --git a/zerver/lib/retention.py b/zerver/lib/retention.py
index 7ecbb256641..7d09336f821 100644
--- a/zerver/lib/retention.py
+++ b/zerver/lib/retention.py
@@ -328,7 +328,7 @@ def delete_messages(msg_ids: list[int]) -> None:
def delete_expired_attachments(realm: Realm) -> None:
- (num_deleted, ignored) = Attachment.objects.filter(
+ (num_deleted, _deletions) = Attachment.objects.filter(
messages__isnull=True,
scheduled_messages__isnull=True,
realm_id=realm.id,
diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py
index f5bad2a6a84..399dcecff68 100644
--- a/zerver/lib/test_classes.py
+++ b/zerver/lib/test_classes.py
@@ -1567,7 +1567,7 @@ Output:
try:
stream = get_stream(stream_name, user_profile.realm)
except Stream.DoesNotExist:
- stream, from_stream_creation = create_stream_if_needed(
+ stream, _from_stream_creation = create_stream_if_needed(
realm,
stream_name,
invite_only=invite_only,
diff --git a/zerver/lib/timezone.py b/zerver/lib/timezone.py
index 48d2daef5ab..0c9c41eb9c4 100644
--- a/zerver/lib/timezone.py
+++ b/zerver/lib/timezone.py
@@ -10,7 +10,7 @@ def get_canonical_timezone_map() -> dict[str, str]:
for line in f:
fields = line.split()
if fields and "link".startswith(fields[0].lower()): # zic(8) accepts any prefix of Link
- code, name, alias = fields
+ _code, name, alias = fields
canonical[alias] = name
return canonical
diff --git a/zerver/lib/typed_endpoint.py b/zerver/lib/typed_endpoint.py
index 1d8d7520b37..6acc7e9df7b 100644
--- a/zerver/lib/typed_endpoint.py
+++ b/zerver/lib/typed_endpoint.py
@@ -240,7 +240,7 @@ def parse_single_parameter(
# metadata attached to Annotated. Note that we do not transform
# param_type to its underlying type because the Annotated metadata might
# still be needed by other parties like Pydantic.
- ignored_type, *annotations = get_args(param_type)
+ _type, *annotations = get_args(param_type)
for annotation in annotations:
if not isinstance(annotation, ApiParamConfig):
continue
diff --git a/zerver/management/commands/email_mirror.py b/zerver/management/commands/email_mirror.py
index 37543f51ad7..fc9c81cf920 100644
--- a/zerver/management/commands/email_mirror.py
+++ b/zerver/management/commands/email_mirror.py
@@ -63,9 +63,9 @@ def get_imap_messages() -> Generator[EmailMessage, None, None]:
try:
mbox.select(settings.EMAIL_GATEWAY_IMAP_FOLDER)
try:
- status, num_ids_data = mbox.search(None, "ALL")
+ _status, num_ids_data = mbox.search(None, "ALL")
for message_id in num_ids_data[0].split():
- status, msg_data = mbox.fetch(message_id, "(RFC822)")
+ _status, msg_data = mbox.fetch(message_id, "(RFC822)")
assert isinstance(msg_data[0], tuple)
msg_as_bytes = msg_data[0][1]
yield email.parser.BytesParser(
diff --git a/zerver/migrations/0401_migrate_old_realm_reactivation_links.py b/zerver/migrations/0401_migrate_old_realm_reactivation_links.py
index 9457beb0bb2..f3f274c35c6 100644
--- a/zerver/migrations/0401_migrate_old_realm_reactivation_links.py
+++ b/zerver/migrations/0401_migrate_old_realm_reactivation_links.py
@@ -32,7 +32,7 @@ def fix_old_realm_reactivation_confirmations(
return
# .content_type of these old Confirmation will be changed to this.
- realm_reactivation_status_content_type, created = ContentType.objects.get_or_create(
+ realm_reactivation_status_content_type, _created = ContentType.objects.get_or_create(
model="realmreactivationstatus", app_label="zerver"
)
diff --git a/zerver/migrations/0564_purge_nagios_messages.py b/zerver/migrations/0564_purge_nagios_messages.py
index 06143eb4ba1..eb00b3c43f1 100644
--- a/zerver/migrations/0564_purge_nagios_messages.py
+++ b/zerver/migrations/0564_purge_nagios_messages.py
@@ -13,7 +13,7 @@ def purge_nagios_messages(apps: StateApps, schema_editor: BaseDatabaseSchemaEdit
with connection.cursor() as cursor:
cursor.execute("SELECT MIN(id), MAX(id) FROM zerver_message")
- (min_id, max_id) = cursor.fetchone()
+ (min_id, _max_id) = cursor.fetchone()
if min_id is None:
return
diff --git a/zerver/tests/test_channel_creation.py b/zerver/tests/test_channel_creation.py
index 889f0ecad65..b21604893bc 100644
--- a/zerver/tests/test_channel_creation.py
+++ b/zerver/tests/test_channel_creation.py
@@ -668,12 +668,12 @@ class TestCreateStreams(ZulipTestCase):
name="role:nobody", realm_for_sharding=realm, is_system_group=True
)
- stream, created = create_stream_if_needed(
+ stream, _created = create_stream_if_needed(
realm, "new stream without acting user", invite_only=True
)
self.assertEqual(stream.can_administer_channel_group.id, nobody_system_group.id)
- stream, created = create_stream_if_needed(
+ stream, _created = create_stream_if_needed(
realm, "new stream with acting user", acting_user=user
)
self.assertCountEqual(stream.can_administer_channel_group.direct_members.all(), [user])
diff --git a/zerver/tests/test_e2ee_push_notifications.py b/zerver/tests/test_e2ee_push_notifications.py
index f171ef51af1..f54ab1b5453 100644
--- a/zerver/tests/test_e2ee_push_notifications.py
+++ b/zerver/tests/test_e2ee_push_notifications.py
@@ -205,7 +205,9 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):
hamlet = self.example_user("hamlet")
aaron = self.example_user("aaron")
- unused, registered_device_android = self.register_push_devices_for_notification()
+ _registered_device_apple, registered_device_android = (
+ self.register_push_devices_for_notification()
+ )
message_id = self.send_personal_message(
from_user=aaron, to_user=hamlet, skip_capture_on_commit_callbacks=True
)
@@ -892,7 +894,9 @@ class RequireE2EEPushNotificationsSettingTest(E2EEPushNotificationTestCase):
class SendTestPushNotificationTest(E2EEPushNotificationTestCase):
def test_success_cloud(self) -> None:
hamlet = self.example_user("hamlet")
- unused, registered_device_android = self.register_push_devices_for_notification()
+ _registered_device_apple, registered_device_android = (
+ self.register_push_devices_for_notification()
+ )
with (
self.mock_fcm() as mock_fcm_messaging,
diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.py
index df31c5a95be..3fb2a1affd2 100644
--- a/zerver/tests/test_email_mirror.py
+++ b/zerver/tests/test_email_mirror.py
@@ -189,10 +189,10 @@ class TestEncodeDecode(ZulipTestCase):
address_prefer_text = f"Denmark.{email_token}.prefer-text@testserver"
address_prefer_html = f"Denmark.{email_token}.prefer-html@testserver"
- token, options = decode_email_address(address_prefer_text)
+ _token, options = decode_email_address(address_prefer_text)
self._assert_options(options, prefer_text=True)
- token, options = decode_email_address(address_prefer_html)
+ _token, options = decode_email_address(address_prefer_html)
self._assert_options(options, prefer_text=False)
diff --git a/zerver/tests/test_handle_push_notification.py b/zerver/tests/test_handle_push_notification.py
index aa60397ce8d..b9003c71763 100644
--- a/zerver/tests/test_handle_push_notification.py
+++ b/zerver/tests/test_handle_push_notification.py
@@ -72,10 +72,10 @@ class HandlePushNotificationTest(PushNotificationTestCase):
}
with (
self.mock_fcm() as (
- mock_fcm_app,
+ _mock_fcm_app,
mock_fcm_messaging,
),
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
mock.patch(
"corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
return_value=10,
@@ -240,10 +240,10 @@ class HandlePushNotificationTest(PushNotificationTestCase):
}
with (
self.mock_fcm() as (
- mock_fcm_app,
+ _mock_fcm_app,
mock_fcm_messaging,
),
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
mock.patch(
"corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
return_value=10,
diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py
index f4872f1f229..92402920a67 100644
--- a/zerver/tests/test_markdown.py
+++ b/zerver/tests/test_markdown.py
@@ -579,7 +579,7 @@ class MarkdownFixtureTest(ZulipTestCase):
def test_markdown_no_ignores(self) -> None:
# We do not want any ignored tests to be committed and merged.
- format_tests, linkify_tests = self.load_markdown_tests()
+ format_tests, _linkify_tests = self.load_markdown_tests()
for name, test in format_tests.items():
message = f'Test "{name}" shouldn\'t be ignored.'
is_ignored = test.get("ignore", False)
diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py
index 2a023f0d49c..a53ef852ff4 100644
--- a/zerver/tests/test_message_edit.py
+++ b/zerver/tests/test_message_edit.py
@@ -1628,7 +1628,7 @@ class EditMessageTest(ZulipTestCase):
# has been set properly.
called = False
for call_args in mock_send_event.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "update_message":
self.assertEqual(arg_event["type"], "update_message")
self.assertEqual(
@@ -1686,7 +1686,7 @@ class EditMessageTest(ZulipTestCase):
# has been set properly.
called = False
for call_args in mock_send_event.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "update_message":
self.assertEqual(arg_event["type"], "update_message")
self.assertEqual(
@@ -1741,7 +1741,7 @@ class EditMessageTest(ZulipTestCase):
# Here we assert topic_wildcard_mention_user_ids has been set properly.
called = False
for call_args in mock_send_event.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "update_message":
self.assertEqual(arg_event["type"], "update_message")
self.assertEqual(arg_event["topic_wildcard_mention_user_ids"], [hamlet.id])
@@ -1802,7 +1802,7 @@ class EditMessageTest(ZulipTestCase):
# is removed.
called = False
for call_args in mock_send_event.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "update_message":
self.assertEqual(arg_event["type"], "update_message")
self.assertEqual(arg_event["stream_wildcard_mention_user_ids"], [])
@@ -1927,7 +1927,7 @@ class EditMessageTest(ZulipTestCase):
# Here we assert 'stream_wildcard_mention_user_ids' has been set properly.
called = False
for call_args in mock_send_event.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "update_message":
self.assertEqual(arg_event["type"], "update_message")
self.assertEqual(
@@ -1990,7 +1990,7 @@ class EditMessageTest(ZulipTestCase):
# is removed.
called = False
for call_args in mock_send_event.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "update_message":
self.assertEqual(arg_event["type"], "update_message")
self.assertEqual(arg_event["stream_wildcard_mention_user_ids"], [])
diff --git a/zerver/tests/test_message_move_stream.py b/zerver/tests/test_message_move_stream.py
index 5b546106104..23c6ba1bc4c 100644
--- a/zerver/tests/test_message_move_stream.py
+++ b/zerver/tests/test_message_move_stream.py
@@ -138,7 +138,7 @@ class MessageMoveStreamTest(ZulipTestCase):
self.assert_json_error(result, "Direct messages cannot be moved to channels.")
def test_move_message_to_stream_with_content(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -360,7 +360,7 @@ class MessageMoveStreamTest(ZulipTestCase):
self.assert_length(messages, 5)
def test_move_message_to_stream(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_lt) = self.prepare_move_topics(
"iago",
"test move stream",
"new stream",
@@ -397,7 +397,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_move_message_to_preexisting_topic(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_lt) = self.prepare_move_topics(
"iago",
"test move stream",
"new stream",
@@ -628,7 +628,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_move_message_to_stream_change_later_all_moved(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -658,7 +658,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_move_message_to_preexisting_topic_change_later_all_moved(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -852,8 +852,8 @@ class MessageMoveStreamTest(ZulipTestCase):
def check_move_message_according_to_permission(
username: str, expect_fail: bool = False
) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
- username, "old_stream", "new_stream", "test"
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = (
+ self.prepare_move_topics(username, "old_stream", "new_stream", "test")
)
result = self.client_patch(
"/json/messages/" + str(msg_id),
@@ -1075,7 +1075,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_move_message_to_stream_based_on_can_send_message_group(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"othello", "old_stream", "new_stream", "test"
)
realm = user_profile.realm
@@ -1144,7 +1144,7 @@ class MessageMoveStreamTest(ZulipTestCase):
check_move_message_to_stream(iago, expect_fail=True)
check_move_message_to_stream(desdemona)
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"othello", "old_stream", "new_stream", "test"
)
@@ -1159,7 +1159,7 @@ class MessageMoveStreamTest(ZulipTestCase):
check_move_message_to_stream(iago, expect_fail=True)
check_move_message_to_stream(hamlet)
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"othello", "old_stream", "new_stream", "test"
)
@@ -1174,12 +1174,12 @@ class MessageMoveStreamTest(ZulipTestCase):
check_move_message_to_stream(hamlet, expect_fail=True)
check_move_message_to_stream(desdemona)
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"othello", "old_stream", "new_stream", "test"
)
check_move_message_to_stream(othello)
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"polonius", "old_stream", "new_stream", "test"
)
everyone_group = NamedUserGroup.objects.get(
@@ -1354,7 +1354,7 @@ class MessageMoveStreamTest(ZulipTestCase):
self.assert_move_message("desdemona", stream_1, stream_id=stream_2.id, topic_name="")
def test_move_message_to_stream_with_topic_editing_not_allowed(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"othello", "old_stream_1", "new_stream_1", "test"
)
realm = user_profile.realm
@@ -1407,7 +1407,7 @@ class MessageMoveStreamTest(ZulipTestCase):
self.assert_length(messages, 4)
def test_move_message_to_stream_and_topic(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -1438,7 +1438,7 @@ class MessageMoveStreamTest(ZulipTestCase):
self.assert_json_success(result)
def test_move_many_messages_to_stream_and_topic(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, _old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"iago", "first origin stream", "first destination stream", "first topic"
)
@@ -1456,7 +1456,7 @@ class MessageMoveStreamTest(ZulipTestCase):
# Adding more messages should not increase the number of
# queries
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, _old_stream, new_stream, msg_id, _msg_id_later) = self.prepare_move_topics(
"iago", "second origin stream", "second destination stream", "second topic"
)
for i in range(1, 5):
@@ -1480,7 +1480,7 @@ class MessageMoveStreamTest(ZulipTestCase):
def test_inaccessible_msg_after_stream_change(self) -> None:
"""Simulates the case where message is moved to a stream where user is not a subscribed"""
- (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_lt) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -1562,7 +1562,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_no_notify_move_message_to_stream(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_lt) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -1585,7 +1585,7 @@ class MessageMoveStreamTest(ZulipTestCase):
self.assert_length(messages, 3)
def test_notify_new_thread_move_message_to_stream(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_lt) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -1612,7 +1612,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_notify_old_thread_move_message_to_stream(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(
+ (user_profile, old_stream, new_stream, msg_id, _msg_id_lt) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -1734,7 +1734,7 @@ class MessageMoveStreamTest(ZulipTestCase):
first_stream,
second_stream,
msg_id,
- msg_id_later,
+ _msg_id_later,
) = self.prepare_move_topics("shiva", "first stream", "second stream", "test")
# 'prepare_move_topics' sends 3 messages in the first_stream
@@ -2210,7 +2210,7 @@ class MessageMoveStreamTest(ZulipTestCase):
)
def test_move_message_update_stream_active_status(self) -> None:
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, _old_stream, new_stream, _msg_id, msg_id_later) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
@@ -2256,7 +2256,7 @@ class MessageMoveStreamTest(ZulipTestCase):
def test_move_message_update_private_stream_active_status(self) -> None:
# Goal is to test that we only send the stream status update to subscribers.
- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(
+ (user_profile, _old_stream, new_stream, _msg_id, msg_id_later) = self.prepare_move_topics(
"iago", "test move stream", "new stream", "test"
)
diff --git a/zerver/tests/test_message_move_topic.py b/zerver/tests/test_message_move_topic.py
index 666a92e2f54..0375510ac0b 100644
--- a/zerver/tests/test_message_move_topic.py
+++ b/zerver/tests/test_message_move_topic.py
@@ -437,7 +437,7 @@ class MessageMoveTopicTest(ZulipTestCase):
users_notified_via_muted_topics_event: list[int] = []
users_notified_via_user_topic_event: list[int] = []
for call_args in mock_send_event_on_commit.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "user_topic":
users_notified_via_user_topic_event.append(*arg_notified_users)
elif arg_event["type"] == "muted_topics":
@@ -699,7 +699,7 @@ class MessageMoveTopicTest(ZulipTestCase):
users_notified_via_muted_topics_event: list[int] = []
users_notified_via_user_topic_event: list[int] = []
for call_args in mock_send_event_on_commit.call_args_list:
- (arg_realm, arg_event, arg_notified_users) = call_args[0]
+ (_arg_realm, arg_event, arg_notified_users) = call_args[0]
if arg_event["type"] == "user_topic":
users_notified_via_user_topic_event.append(*arg_notified_users)
elif arg_event["type"] == "muted_topics":
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index ec997396b0d..b1be938b4b1 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -1338,7 +1338,7 @@ class TestAPNs(PushNotificationTestCase):
def test_success(self) -> None:
self.setup_apns_tokens()
with (
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as logger,
):
send_notification.return_value.is_successful = True
@@ -1352,7 +1352,7 @@ class TestAPNs(PushNotificationTestCase):
def test_http_retry_eventually_fails(self) -> None:
self.setup_apns_tokens()
with (
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as logger,
):
send_notification.side_effect = aioapns.exceptions.ConnectionError()
@@ -1365,7 +1365,7 @@ class TestAPNs(PushNotificationTestCase):
def test_other_exception(self) -> None:
self.setup_apns_tokens()
with (
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as logger,
):
send_notification.side_effect = IOError
@@ -1378,7 +1378,7 @@ class TestAPNs(PushNotificationTestCase):
def test_internal_server_error(self) -> None:
self.setup_apns_tokens()
with (
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as logger,
):
send_notification.return_value.is_successful = False
@@ -1398,7 +1398,7 @@ class TestAPNs(PushNotificationTestCase):
server=self.server,
)
with (
- self.mock_apns() as (apns_context, send_notification),
+ self.mock_apns() as (_apns_context, send_notification),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as logger,
):
send_notification.return_value.is_successful = True
diff --git a/zerver/tests/test_queue.py b/zerver/tests/test_queue.py
index 544ae569ce0..7042ab1af30 100644
--- a/zerver/tests/test_queue.py
+++ b/zerver/tests/test_queue.py
@@ -104,7 +104,7 @@ class TestQueueImplementation(ZulipTestCase):
)
assert queue_client.channel
- method, header, message = queue_client.channel.basic_get("test_suite")
+ method, _header, message = queue_client.channel.basic_get("test_suite")
assert method is not None
assert method.delivery_tag is not None
assert message is not None
@@ -112,7 +112,7 @@ class TestQueueImplementation(ZulipTestCase):
result = orjson.loads(message)
self.assertEqual(result["event"], "my_event")
- method, header, message = queue_client.channel.basic_get("test_suite")
+ method, _header, message = queue_client.channel.basic_get("test_suite")
assert message is None
@override_settings(USING_RABBITMQ=True)
diff --git a/zerver/tests/test_rate_limiter.py b/zerver/tests/test_rate_limiter.py
index 4d611690d30..40df27a8c9e 100644
--- a/zerver/tests/test_rate_limiter.py
+++ b/zerver/tests/test_rate_limiter.py
@@ -61,7 +61,7 @@ class RateLimiterBackendBase(ZulipTestCase, ABC):
if key not in self.requests_record:
self.requests_record[key] = []
- ratelimited, secs_to_freedom = obj.rate_limit()
+ ratelimited, _secs_to_freedom = obj.rate_limit()
if not ratelimited:
self.requests_record[key].append(time.time())
diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.py
index 9e8b26d879e..ee6f178935f 100644
--- a/zerver/tests/test_slack_importer.py
+++ b/zerver/tests/test_slack_importer.py
@@ -1040,9 +1040,9 @@ class SlackImporter(ZulipTestCase):
slack_recipient_name_to_zulip_recipient_id,
added_channels,
added_mpims,
- dm_members,
+ _dm_members,
avatar_list,
- em,
+ _em,
) = slack_workspace_to_realm(
"testdomain", realm_id, user_list, "test-realm", "./random_path", {}
)
@@ -1528,7 +1528,7 @@ class SlackImporter(ZulipTestCase):
zerver_usermessage,
attachment,
uploads,
- reaction,
+ _reaction,
) = channel_message_to_zerver_message(
1,
user_data,
@@ -1749,7 +1749,7 @@ class SlackImporter(ZulipTestCase):
zerver_usermessage,
attachment,
uploads,
- reaction,
+ _reaction,
) = channel_message_to_zerver_message(
1,
user_data,
@@ -1841,7 +1841,7 @@ by Pieter
with self.assertLogs(level="INFO"):
# Hacky: We should include a zerver_userprofile, not the empty []
- test_reactions, uploads, zerver_attachment = convert_slack_workspace_messages(
+ test_reactions, uploads, _zerver_attachment = convert_slack_workspace_messages(
"./random_path",
user_list,
2,
diff --git a/zerver/tests/test_slack_message_conversion.py b/zerver/tests/test_slack_message_conversion.py
index 40334327f38..cc43ffc0f6f 100644
--- a/zerver/tests/test_slack_message_conversion.py
+++ b/zerver/tests/test_slack_message_conversion.py
@@ -79,7 +79,7 @@ class SlackMessageConversion(ZulipTestCase):
]
channel_map = {"general": ("C5Z73A7RA", 137)}
message = "Hi <@U08RGD1RD|john>: How are you? <#C5Z73A7RA|general>"
- text, mentioned_users, has_link = convert_to_zulip_markdown(
+ text, mentioned_users, _has_link = convert_to_zulip_markdown(
message, users, channel_map, slack_user_map
)
full_name = get_user_full_name(users[1])
@@ -91,7 +91,7 @@ class SlackMessageConversion(ZulipTestCase):
# multiple mentioning
message = "Hi <@U08RGD1RD|john>: How are you?<@U0CBK5KAT> asked."
- text, mentioned_users, has_link = convert_to_zulip_markdown(
+ text, mentioned_users, _has_link = convert_to_zulip_markdown(
message, users, channel_map, slack_user_map
)
self.assertEqual(text, "Hi @**John Doe**: How are you?@**aaron.anzalone** asked.")
@@ -99,7 +99,7 @@ class SlackMessageConversion(ZulipTestCase):
# Check wrong mentioning
message = "Hi <@U08RGD1RD|jon>: How are you?"
- text, mentioned_users, has_link = convert_to_zulip_markdown(
+ text, mentioned_users, _has_link = convert_to_zulip_markdown(
message, users, channel_map, slack_user_map
)
self.assertEqual(text, message)
@@ -109,20 +109,28 @@ class SlackMessageConversion(ZulipTestCase):
slack_user_map: dict[str, int] = {}
message = "<http://journals.plos.org/plosone/article>"
- text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], {}, slack_user_map)
+ text, _mentioned_users, has_link = convert_to_zulip_markdown(
+ message, [], {}, slack_user_map
+ )
self.assertEqual(text, "http://journals.plos.org/plosone/article")
self.assertEqual(has_link, True)
message = "<http://chat.zulip.org/help/logging-in|Help logging in to CZO>"
- text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], {}, slack_user_map)
+ text, _mentioned_users, has_link = convert_to_zulip_markdown(
+ message, [], {}, slack_user_map
+ )
self.assertEqual(text, "[Help logging in to CZO](http://chat.zulip.org/help/logging-in)")
self.assertEqual(has_link, True)
message = "<mailto:[email protected]>"
- text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], {}, slack_user_map)
+ text, _mentioned_users, has_link = convert_to_zulip_markdown(
+ message, [], {}, slack_user_map
+ )
self.assertEqual(text, "mailto:[email protected]")
self.assertEqual(has_link, True)
message = "random message"
- text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], {}, slack_user_map)
+ text, _mentioned_users, has_link = convert_to_zulip_markdown(
+ message, [], {}, slack_user_map
+ )
self.assertEqual(has_link, False)
diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py
index d30f154a216..9475a541f3d 100644
--- a/zerver/tests/test_upload.py
+++ b/zerver/tests/test_upload.py
@@ -1061,7 +1061,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
with self.settings(DEVELOPMENT=False):
response = self.client_get(url)
assert settings.LOCAL_UPLOADS_DIR is not None
- test_run, worker = os.path.split(os.path.dirname(settings.LOCAL_UPLOADS_DIR))
+ _test_run, _worker = os.path.split(os.path.dirname(settings.LOCAL_UPLOADS_DIR))
self.assertEqual(
response["X-Accel-Redirect"],
"/internal/local/uploads/" + fp_path + "/" + name_str_for_test,
diff --git a/zerver/views/home.py b/zerver/views/home.py
index b5811e47fd6..5b4b6a97717 100644
--- a/zerver/views/home.py
+++ b/zerver/views/home.py
@@ -128,7 +128,7 @@ def detect_narrowed_window(
# TODO: We should support stream IDs and direct messages here as well.
narrow_stream_name = request.GET.get("stream")
assert narrow_stream_name is not None
- (narrow_stream, ignored_sub) = access_stream_by_name(user_profile, narrow_stream_name)
+ (narrow_stream, _sub) = access_stream_by_name(user_profile, narrow_stream_name)
narrow = [NeverNegatedNarrowTerm(operator="stream", operand=narrow_stream.name)]
except Exception:
logging.warning("Invalid narrow requested, ignoring", extra=dict(request=request))
diff --git a/zerver/views/invite.py b/zerver/views/invite.py
index 2eb495068fd..977342fb84b 100644
--- a/zerver/views/invite.py
+++ b/zerver/views/invite.py
@@ -91,7 +91,7 @@ def access_streams_for_invite(stream_ids: list[int], user_profile: UserProfile)
for stream_id in stream_ids:
try:
- (stream, sub) = access_stream_by_id(user_profile, stream_id)
+ (stream, _sub) = access_stream_by_id(user_profile, stream_id)
except JsonableError:
raise JsonableError(
_("Invalid channel ID {channel_id}. No invites were sent.").format(
diff --git a/zerver/views/message_flags.py b/zerver/views/message_flags.py
index d74f6ce3fdc..4622a79f744 100644
--- a/zerver/views/message_flags.py
+++ b/zerver/views/message_flags.py
@@ -149,7 +149,7 @@ def mark_all_as_read(request: HttpRequest, user_profile: UserProfile) -> HttpRes
def mark_stream_as_read(
request: HttpRequest, user_profile: UserProfile, *, stream_id: Json[int]
) -> HttpResponse:
- stream, sub = access_stream_by_id(user_profile, stream_id)
+ stream, _sub = access_stream_by_id(user_profile, stream_id)
assert stream.recipient_id is not None
count = do_mark_stream_messages_as_read(user_profile, stream.recipient_id)
@@ -169,7 +169,7 @@ def mark_topic_as_read(
topic_name: str,
stream_id: Json[int],
) -> HttpResponse:
- stream, sub = access_stream_by_id(user_profile, stream_id)
+ stream, _sub = access_stream_by_id(user_profile, stream_id)
assert stream.recipient_id is not None
if topic_name:
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
index 5cd3c557fda..48a900cfa5a 100644
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -157,7 +157,7 @@ def user_directly_controls_user(user_profile: UserProfile, target: UserProfile)
def deactivate_stream_backend(
request: HttpRequest, user_profile: UserProfile, stream_id: int
) -> HttpResponse:
- (stream, sub) = access_stream_for_delete_or_update_requiring_metadata_access(
+ (stream, _sub) = access_stream_for_delete_or_update_requiring_metadata_access(
user_profile, stream_id
)
do_deactivate_stream(stream, acting_user=user_profile)
@@ -169,7 +169,7 @@ def deactivate_stream_backend(
def add_default_stream(
request: HttpRequest, user_profile: UserProfile, *, stream_id: Json[int]
) -> HttpResponse:
- (stream, sub) = access_stream_by_id(user_profile, stream_id)
+ (stream, _sub) = access_stream_by_id(user_profile, stream_id)
if stream.invite_only:
raise JsonableError(_("Private channels cannot be made default."))
do_add_default_stream(stream)
@@ -188,7 +188,7 @@ def create_default_stream_group(
) -> HttpResponse:
streams = []
for stream_name in stream_names:
- (stream, sub) = access_stream_by_name(user_profile, stream_name)
+ (stream, _sub) = access_stream_by_name(user_profile, stream_name)
streams.append(stream)
do_create_default_stream_group(user_profile.realm, group_name, description, streams)
return json_success(request)
@@ -228,7 +228,7 @@ def update_default_stream_group_streams(
group = access_default_stream_group_by_id(user_profile.realm, group_id)
streams = []
for stream_name in stream_names:
- (stream, sub) = access_stream_by_name(user_profile, stream_name)
+ (stream, _sub) = access_stream_by_name(user_profile, stream_name)
streams.append(stream)
if op == "add":
@@ -255,7 +255,7 @@ def remove_default_stream_group(
def remove_default_stream(
request: HttpRequest, user_profile: UserProfile, *, stream_id: Json[int]
) -> HttpResponse:
- (stream, sub) = access_stream_by_id(
+ (stream, _sub) = access_stream_by_id(
user_profile,
stream_id,
require_content_access=False,
@@ -1091,7 +1091,7 @@ def get_subscribers_backend(
*,
stream_id: Annotated[NonNegativeInt, ApiParamConfig("stream", path_only=True)],
) -> HttpResponse:
- (stream, sub) = access_stream_by_id(
+ (stream, _sub) = access_stream_by_id(
user_profile,
stream_id,
require_content_access=False,
@@ -1141,7 +1141,7 @@ def get_stream_backend(
*,
stream_id: PathOnly[int],
) -> HttpResponse:
- (stream, sub) = access_stream_by_id(user_profile, stream_id, require_content_access=False)
+ (stream, _sub) = access_stream_by_id(user_profile, stream_id, require_content_access=False)
recent_traffic = get_streams_traffic({stream.id}, user_profile.realm)
anonymous_group_membership = get_anonymous_group_membership_dict_for_streams([stream])
@@ -1180,7 +1180,7 @@ def get_topics_backend(
else:
assert user_profile is not None
- (stream, sub) = access_stream_by_id(user_profile, stream_id)
+ (stream, _sub) = access_stream_by_id(user_profile, stream_id)
assert stream.recipient_id is not None
result = get_topic_history_for_stream(
@@ -1202,7 +1202,7 @@ def delete_in_topic(
stream_id: PathOnly[NonNegativeInt],
topic_name: str,
) -> HttpResponse:
- stream, ignored_sub = access_stream_by_id(user_profile, stream_id)
+ stream, _sub = access_stream_by_id(user_profile, stream_id)
topic_name = maybe_rename_general_chat_to_empty_topic(topic_name)
messages = messages_for_topic(
@@ -1273,7 +1273,7 @@ def json_get_stream_id(
*,
stream_name: Annotated[str, ApiParamConfig("stream")],
) -> HttpResponse:
- (stream, sub) = access_stream_by_name(user_profile, stream_name)
+ (stream, _sub) = access_stream_by_name(user_profile, stream_name)
return json_success(request, data={"stream_id": stream.id})
@@ -1368,7 +1368,7 @@ def get_stream_email_address(
sender_id: Json[NonNegativeInt] | None = None,
stream_id: Annotated[NonNegativeInt, ApiParamConfig("stream", path_only=True)],
) -> HttpResponse:
- (stream, sub) = access_stream_by_id(
+ (stream, _sub) = access_stream_by_id(
user_profile,
stream_id,
)
diff --git a/zerver/views/user_topics.py b/zerver/views/user_topics.py
index 91efe73e5a8..a8b77babe9f 100644
--- a/zerver/views/user_topics.py
+++ b/zerver/views/user_topics.py
@@ -29,10 +29,10 @@ def mute_topic(
date_muted: datetime,
) -> None:
if stream_name is not None:
- (stream, sub) = access_stream_by_name(user_profile, stream_name)
+ (stream, _sub) = access_stream_by_name(user_profile, stream_name)
else:
assert stream_id is not None
- (stream, sub) = access_stream_by_id(user_profile, stream_id)
+ (stream, _sub) = access_stream_by_id(user_profile, stream_id)
do_set_user_topic_visibility_policy(
user_profile,
@@ -107,7 +107,7 @@ def update_user_topic(
error = _("Invalid channel ID")
stream = access_stream_to_remove_visibility_policy_by_id(user_profile, stream_id, error)
else:
- (stream, sub) = access_stream_by_id(user_profile, stream_id)
+ (stream, _sub) = access_stream_by_id(user_profile, stream_id)
do_set_user_topic_visibility_policy(
user_profile, stream, topic, visibility_policy=visibility_policy
diff --git a/zerver/views/users.py b/zerver/views/users.py
index 9103b977e44..af10ba70862 100644
--- a/zerver/views/users.py
+++ b/zerver/views/users.py
@@ -484,13 +484,13 @@ def patch_bot_backend(
if default_sending_stream == "":
stream: Stream | None = None
else:
- (stream, sub) = access_stream_by_name(user_profile, default_sending_stream)
+ (stream, _sub) = access_stream_by_name(user_profile, default_sending_stream)
do_change_default_sending_stream(bot, stream, acting_user=user_profile)
if default_events_register_stream is not None:
if default_events_register_stream == "":
stream = None
else:
- (stream, sub) = access_stream_by_name(user_profile, default_events_register_stream)
+ (stream, _sub) = access_stream_by_name(user_profile, default_events_register_stream)
do_change_default_events_register_stream(bot, stream, acting_user=user_profile)
if default_all_public_streams is not None:
do_change_default_all_public_streams(
@@ -634,13 +634,13 @@ def add_bot_backend(
default_sending_stream = None
if default_sending_stream_name is not None:
- (default_sending_stream, ignored_sub) = access_stream_by_name(
+ (default_sending_stream, _sub) = access_stream_by_name(
user_profile, default_sending_stream_name
)
default_events_register_stream = None
if default_events_register_stream_name is not None:
- (default_events_register_stream, ignored_sub) = access_stream_by_name(
+ (default_events_register_stream, _sub) = access_stream_by_name(
user_profile, default_events_register_stream_name
)
@@ -903,7 +903,7 @@ def get_subscription_backend(
user_id: PathOnly[Json[int]],
) -> HttpResponse:
target_user = access_user_by_id(user_profile, user_id, for_admin=False)
- (stream, sub) = access_stream_by_id(user_profile, stream_id, require_content_access=False)
+ (_stream, _sub) = access_stream_by_id(user_profile, stream_id, require_content_access=False)
subscription_status = {"is_subscribed": subscribed_to_stream(target_user, stream_id)}
diff --git a/zerver/views/video_calls.py b/zerver/views/video_calls.py
index 2d5cb93e023..d87541c8ba5 100644
--- a/zerver/views/video_calls.py
+++ b/zerver/views/video_calls.py
@@ -104,7 +104,7 @@ def register_zoom_user(request: HttpRequest) -> HttpResponse:
assert request.user.is_authenticated
oauth = get_zoom_session(request.user)
- authorization_url, state = oauth.authorization_url(
+ authorization_url, _state = oauth.authorization_url(
"https://zoom.us/oauth/authorize",
state=json.dumps(
{"realm": get_subdomain(request), "sid": get_zoom_sid(request)},
diff --git a/zerver/webhooks/front/view.py b/zerver/webhooks/front/view.py
index b7f826161f8..3e7ed12f989 100644
--- a/zerver/webhooks/front/view.py
+++ b/zerver/webhooks/front/view.py
@@ -55,7 +55,7 @@ def get_outbound_message_body(payload: WildValue) -> str:
def get_outbound_reply_body(payload: WildValue) -> str:
- link, outbox, inbox, subject = get_message_data(payload)
+ link, outbox, inbox, _subject = get_message_data(payload)
return f"[Outbound reply]({link}) from **{inbox}** to **{outbox}**."
diff --git a/zerver/webhooks/librato/view.py b/zerver/webhooks/librato/view.py
index e89d048534c..fba1d962af9 100644
--- a/zerver/webhooks/librato/view.py
+++ b/zerver/webhooks/librato/view.py
@@ -93,7 +93,7 @@ class LibratoWebhookHandler(LibratoWebhookParser):
if self.attachments:
return "Snapshots"
topic_template = "Alert {alert_name}"
- alert_id, alert_name, alert_url, alert_runbook_url = self.parse_alert()
+ _alert_id, alert_name, _alert_url, _alert_runbook_url = self.parse_alert()
return topic_template.format(alert_name=alert_name)
def handle_alert_clear_message(self) -> str:
@@ -101,7 +101,7 @@ class LibratoWebhookHandler(LibratoWebhookParser):
trigger_time = datetime.fromtimestamp(
self.payload["trigger_time"], tz=timezone.utc
).strftime("%Y-%m-%d %H:%M:%S")
- alert_id, alert_name, alert_url, alert_runbook_url = self.parse_alert()
+ _alert_id, alert_name, alert_url, _alert_runbook_url = self.parse_alert()
content = alert_clear_template.format(
alert_name=alert_name, alert_url=alert_url, trigger_time=trigger_time
)
@@ -123,7 +123,7 @@ class LibratoWebhookHandler(LibratoWebhookParser):
def handle_alert_violation_message(self) -> str:
alert_violation_template = "Alert [alert_name]({alert_url}) has triggered! "
- alert_id, alert_name, alert_url, alert_runbook_url = self.parse_alert()
+ _alert_id, alert_name, alert_url, alert_runbook_url = self.parse_alert()
content = alert_violation_template.format(alert_name=alert_name, alert_url=alert_url)
if alert_runbook_url:
alert_runbook_template = "[Reaction steps]({alert_runbook_url}):"
diff --git a/zilencer/auth.py b/zilencer/auth.py
index 24e0239cfe1..a0ccad76ead 100644
--- a/zilencer/auth.py
+++ b/zilencer/auth.py
@@ -166,7 +166,7 @@ def remote_server_dispatch(request: HttpRequest, /, **kwargs: Any) -> HttpRespon
result = get_target_view_function_or_response(request, kwargs)
if isinstance(result, HttpResponse):
return result
- target_function, view_flags = result
+ target_function, _view_flags = result
return authenticated_remote_server_view(target_function)(request, **kwargs)
diff --git a/zilencer/views.py b/zilencer/views.py
index 16f8d12c368..5b65a100f96 100644
--- a/zilencer/views.py
+++ b/zilencer/views.py
@@ -652,7 +652,7 @@ def unregister_remote_push_device(
update_remote_realm_last_request_datetime_helper(request, server, realm_uuid, user_uuid)
- (num_deleted, ignored) = (
+ (num_deleted, _deletions) = (
get_remote_push_device_token(token=token, kind=token_kind, server=server)
.filter(user_identity.filter_q())
.delete()