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 C413 Unnecessary `list` call around `sorted()`.

Anders Kaseorg69e94b59913b
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index 7355a428e22..3852813fdc4 100644
--- a/zerver/lib/push_notifications.py
+++ b/zerver/lib/push_notifications.py
@@ -1002,7 +1002,7 @@ def handle_remove_push_notification(user_profile_id: int, message_ids: List[int]
# space consume 12 bytes, and 12 x 200 = 2400 bytes is still well
# below the 4KB limit (leaving plenty of space for metadata).
MAX_APNS_MESSAGE_IDS = 200
- truncated_message_ids = list(sorted(message_ids))[-MAX_APNS_MESSAGE_IDS:]
+ truncated_message_ids = sorted(message_ids)[-MAX_APNS_MESSAGE_IDS:]
gcm_payload, gcm_options = get_remove_payload_gcm(user_profile, truncated_message_ids)
apns_payload = get_remove_payload_apns(user_profile, truncated_message_ids)
diff --git a/zerver/models.py b/zerver/models.py
index a85c289b707..5d9e7f3adf2 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -1283,7 +1283,7 @@ class RealmFilter(models.Model):
# Report patterns missing in linkifier pattern.
missing_in_pattern_set = found_group_set - group_set
if len(missing_in_pattern_set) > 0:
- name = list(sorted(missing_in_pattern_set))[0]
+ name = min(missing_in_pattern_set)
raise ValidationError(
_("Group %(name)r in URL format string is not present in linkifier pattern."),
params={"name": name},
@@ -1295,7 +1295,7 @@ class RealmFilter(models.Model):
# We just report the first missing pattern here. Users can
# incrementally resolve errors if there are multiple
# missing patterns.
- name = list(sorted(missing_in_url_set))[0]
+ name = min(missing_in_url_set)
raise ValidationError(
_("Group %(name)r in linkifier pattern is not present in URL format string."),
params={"name": name},
diff --git a/zilencer/views.py b/zilencer/views.py
index 9210ac18176..07c44792743 100644
--- a/zilencer/views.py
+++ b/zilencer/views.py
@@ -261,7 +261,7 @@ def remote_server_notify_push(
MAX_MESSAGE_IDS = 200
if payload and payload.get("event") == "remove" and payload.get("zulip_message_ids"):
ids = [int(id) for id in payload["zulip_message_ids"].split(",")]
- truncated_ids = list(sorted(ids))[-MAX_MESSAGE_IDS:]
+ truncated_ids = sorted(ids)[-MAX_MESSAGE_IDS:]
payload["zulip_message_ids"] = ",".join(str(id) for id in truncated_ids)
return payload