From 51d1ccb064f39e18e69a8fe3ebac8efe4c8b1987 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 4 Nov 2022 13:54:52 -0700 Subject: [PATCH] build_emoji: Guard mutable default with read-only type. Signed-off-by: Anders Kaseorg --- tools/setup/emoji/build_emoji | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/setup/emoji/build_emoji b/tools/setup/emoji/build_emoji index 01eb83055c..88d30a6251 100755 --- a/tools/setup/emoji/build_emoji +++ b/tools/setup/emoji/build_emoji @@ -5,7 +5,7 @@ import os import shutil import sys -from typing import Any, Dict, Iterator, List, Optional +from typing import Any, Dict, Iterator, List, Optional, Sequence import orjson @@ -127,13 +127,13 @@ def percent(f: float) -> str: return f"{f * 100:0.3f}%" -def get_square_size(emoji_data: List[Dict[str, Any]]) -> int: +def get_square_size(emoji_data: Sequence[Dict[str, Any]]) -> int: """ Spritesheets are usually NxN squares, and we have to infer N from the sheet_x/sheet_y values of emojis. """ - def get_offsets(emoji_data: List[Dict[str, Any]]) -> Iterator[int]: + def get_offsets(emoji_data: Sequence[Dict[str, Any]]) -> Iterator[int]: for emoji_dict in emoji_data: yield emoji_dict["sheet_x"] yield emoji_dict["sheet_y"] @@ -151,7 +151,7 @@ def generate_sprite_css_files( emoji_data: List[Dict[str, Any]], emojiset: str, alt_name: str, - fallback_emoji_data: List[Dict[str, Any]], + fallback_emoji_data: Sequence[Dict[str, Any]], ) -> None: """ Spritesheets are usually NxN squares. @@ -281,7 +281,7 @@ def setup_emoji_farms(cache_path: str, emoji_data: List[Dict[str, Any]]) -> None emojiset: str, emoji_data: List[Dict[str, Any]], alt_name: Optional[str] = None, - fallback_emoji_data: List[Dict[str, Any]] = list(), + fallback_emoji_data: Sequence[Dict[str, Any]] = [], ) -> None: # `alt_name` is an optional parameter that we use to avoid duplicating below # code. It is only used while setting up google-blob emoji set as it is just