From 0b95d83f099acc98950ed3578c79c5458006a441 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 31 Jul 2023 13:29:52 -0700 Subject: [PATCH] ruff: Fix PERF402 Use `list` or `list.copy` to create a copy of a list. Signed-off-by: Anders Kaseorg --- puppet/zulip/files/postgresql/wal-g-exporter | 3 +-- tools/setup/emoji/emoji_setup_utils.py | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/puppet/zulip/files/postgresql/wal-g-exporter b/puppet/zulip/files/postgresql/wal-g-exporter index 7d422ad057..c0e7a9565c 100755 --- a/puppet/zulip/files/postgresql/wal-g-exporter +++ b/puppet/zulip/files/postgresql/wal-g-exporter @@ -49,8 +49,7 @@ class WalGPrometheusServer(BaseHTTPRequestHandler): if self.metric_values[metric_name]: # Print preamble lines += self.metrics[metric_name] - for metric_value in self.metric_values[metric_name].values(): - lines.append(metric_value) + lines += self.metric_values[metric_name].values() lines.append("") self.wfile.write("\n".join(lines).encode()) diff --git a/tools/setup/emoji/emoji_setup_utils.py b/tools/setup/emoji/emoji_setup_utils.py index cbb06d2ade..2baa139e72 100644 --- a/tools/setup/emoji/emoji_setup_utils.py +++ b/tools/setup/emoji/emoji_setup_utils.py @@ -116,14 +116,11 @@ def generate_codepoint_to_name_map(emoji_name_maps: Dict[str, Dict[str, Any]]) - def generate_codepoint_to_names_map( emoji_name_maps: Dict[str, Dict[str, Any]] ) -> Dict[str, List[str]]: - codepoint_to_names: Dict[str, List[str]] = {} - for emoji_code, name_info in emoji_name_maps.items(): - # The first element of the names list is always the canonical name. - names = [name_info["canonical_name"]] - for alias in name_info["aliases"]: - names.append(alias) - codepoint_to_names[emoji_code] = names - return codepoint_to_names + # The first element of the names list is always the canonical name. + return { + emoji_code: [name_info["canonical_name"], *name_info["aliases"]] + for emoji_code, name_info in emoji_name_maps.items() + } def generate_name_to_codepoint_map(emoji_name_maps: Dict[str, Dict[str, Any]]) -> Dict[str, str]: