ruff: Fix C413 Unnecessary `list` call around `sorted()`.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-10-29 18:32:32 -04:00 committed by Tim Abbott
parent 9e53f0c756
commit 69e94b5991
3 changed files with 4 additions and 4 deletions

View File

@ -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 # space consume 12 bytes, and 12 x 200 = 2400 bytes is still well
# below the 4KB limit (leaving plenty of space for metadata). # below the 4KB limit (leaving plenty of space for metadata).
MAX_APNS_MESSAGE_IDS = 200 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) gcm_payload, gcm_options = get_remove_payload_gcm(user_profile, truncated_message_ids)
apns_payload = get_remove_payload_apns(user_profile, truncated_message_ids) apns_payload = get_remove_payload_apns(user_profile, truncated_message_ids)

View File

@ -1283,7 +1283,7 @@ class RealmFilter(models.Model):
# Report patterns missing in linkifier pattern. # Report patterns missing in linkifier pattern.
missing_in_pattern_set = found_group_set - group_set missing_in_pattern_set = found_group_set - group_set
if len(missing_in_pattern_set) > 0: if len(missing_in_pattern_set) > 0:
name = list(sorted(missing_in_pattern_set))[0] name = min(missing_in_pattern_set)
raise ValidationError( raise ValidationError(
_("Group %(name)r in URL format string is not present in linkifier pattern."), _("Group %(name)r in URL format string is not present in linkifier pattern."),
params={"name": name}, params={"name": name},
@ -1295,7 +1295,7 @@ class RealmFilter(models.Model):
# We just report the first missing pattern here. Users can # We just report the first missing pattern here. Users can
# incrementally resolve errors if there are multiple # incrementally resolve errors if there are multiple
# missing patterns. # missing patterns.
name = list(sorted(missing_in_url_set))[0] name = min(missing_in_url_set)
raise ValidationError( raise ValidationError(
_("Group %(name)r in linkifier pattern is not present in URL format string."), _("Group %(name)r in linkifier pattern is not present in URL format string."),
params={"name": name}, params={"name": name},

View File

@ -261,7 +261,7 @@ def remote_server_notify_push(
MAX_MESSAGE_IDS = 200 MAX_MESSAGE_IDS = 200
if payload and payload.get("event") == "remove" and payload.get("zulip_message_ids"): if payload and payload.get("event") == "remove" and payload.get("zulip_message_ids"):
ids = [int(id) for id in payload["zulip_message_ids"].split(",")] 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) payload["zulip_message_ids"] = ",".join(str(id) for id in truncated_ids)
return payload return payload