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

Anders Kaseorg77c15547e67e
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py
index 0499a2f157c..3f0fa26ecbc 100644
--- a/zerver/actions/message_edit.py
+++ b/zerver/actions/message_edit.py
@@ -721,7 +721,7 @@ def do_update_message(
)
subscriber_ids = set(subscriptions.values_list("user_profile_id", flat=True))
- users_to_be_notified += list(map(subscriber_info, sorted(list(subscriber_ids))))
+ users_to_be_notified += list(map(subscriber_info, sorted(subscriber_ids)))
# UserTopic updates and the content of notifications depend on
# whether we've moved the entire topic, or just part of it. We
diff --git a/zerver/actions/streams.py b/zerver/actions/streams.py
index e206c4fbb89..9832492b52d 100644
--- a/zerver/actions/streams.py
+++ b/zerver/actions/streams.py
@@ -397,7 +397,7 @@ def send_peer_subscriber_events(
type="subscription",
op=op,
stream_ids=[stream_id],
- user_ids=sorted(list(altered_user_ids)),
+ user_ids=sorted(altered_user_ids),
)
send_event(realm, event, peer_user_ids)
@@ -435,7 +435,7 @@ def send_peer_subscriber_events(
type="subscription",
op=op,
stream_ids=[stream_id],
- user_ids=sorted(list(altered_user_ids)),
+ user_ids=sorted(altered_user_ids),
)
send_event(realm, event, peer_user_ids)
@@ -444,7 +444,7 @@ def send_peer_subscriber_events(
event = dict(
type="subscription",
op=op,
- stream_ids=sorted(list(stream_ids)),
+ stream_ids=sorted(stream_ids),
user_ids=[user_id],
)
send_event(realm, event, peer_user_ids)
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py
index e73ea162399..f5a6e066841 100644
--- a/zerver/lib/digest.py
+++ b/zerver/lib/digest.py
@@ -306,7 +306,7 @@ def bulk_get_digest_context(
# Get all the recent topics for all the users. This does the heavy
# lifting of making an expensive query to the Message table. Then
# for each user, we filter to just the streams they care about.
- recent_topics = get_recent_topics(sorted(list(all_stream_ids)), cutoff_date)
+ recent_topics = get_recent_topics(sorted(all_stream_ids), cutoff_date)
stream_map = get_slim_stream_map(all_stream_ids)
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 74d5b29f810..9af8a15dfb7 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -1095,7 +1095,7 @@ def apply_event(
for sub in sub_dict:
if sub["stream_id"] in stream_ids:
subscribers = set(sub["subscribers"]) | user_ids
- sub["subscribers"] = sorted(list(subscribers))
+ sub["subscribers"] = sorted(subscribers)
elif event["op"] == "peer_remove":
if include_subscribers:
stream_ids = set(event["stream_ids"])
@@ -1109,7 +1109,7 @@ def apply_event(
for sub in sub_dict:
if sub["stream_id"] in stream_ids:
subscribers = set(sub["subscribers"]) - user_ids
- sub["subscribers"] = sorted(list(subscribers))
+ sub["subscribers"] = sorted(subscribers)
else:
raise AssertionError("Unexpected event type {type}/{op}".format(**event))
elif event["type"] == "presence":
diff --git a/zerver/lib/export.py b/zerver/lib/export.py
index 2092aff260f..e1295a3c5fb 100644
--- a/zerver/lib/export.py
+++ b/zerver/lib/export.py
@@ -1330,7 +1330,7 @@ def export_partial_message_files(
all_message_ids |= message_ids
- message_id_chunks = chunkify(sorted(list(all_message_ids)), chunk_size=MESSAGE_BATCH_CHUNK_SIZE)
+ message_id_chunks = chunkify(sorted(all_message_ids), chunk_size=MESSAGE_BATCH_CHUNK_SIZE)
write_message_partials(
realm=realm,
@@ -2177,7 +2177,7 @@ def export_messages_single_user(
all_message_ids |= reaction_message_ids
dump_file_id = 1
- for message_id_chunk in chunkify(sorted(list(all_message_ids)), MESSAGE_BATCH_CHUNK_SIZE):
+ for message_id_chunk in chunkify(sorted(all_message_ids), MESSAGE_BATCH_CHUNK_SIZE):
fat_query = (
UserMessage.objects.select_related("message", "message__sending_client")
.filter(user_profile=user_profile, message_id__in=message_id_chunk)
diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py
index a4d305e67ff..ed790cd9416 100644
--- a/zerver/webhooks/github/view.py
+++ b/zerver/webhooks/github/view.py
@@ -358,7 +358,7 @@ def get_team_body(helper: Helper) -> str:
new_visibility = payload["team"]["privacy"].tame(check_string)
return f"Team visibility changed to `{new_visibility}`"
- missing_keys = "/".join(sorted(list(changes.keys())))
+ missing_keys = "/".join(sorted(changes.keys()))
helper.log_unsupported(f"team/edited (changes: {missing_keys})")
# Do our best to give useful info to the customer--at least