build_emoji: Guard mutable default with read-only type.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-11-04 13:54:52 -07:00 committed by Tim Abbott
parent 4316f47f8d
commit 51d1ccb064
1 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,7 @@
import os import os
import shutil import shutil
import sys import sys
from typing import Any, Dict, Iterator, List, Optional from typing import Any, Dict, Iterator, List, Optional, Sequence
import orjson import orjson
@ -127,13 +127,13 @@ def percent(f: float) -> str:
return f"{f * 100:0.3f}%" 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 Spritesheets are usually NxN squares, and we have to
infer N from the sheet_x/sheet_y values of emojis. 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: for emoji_dict in emoji_data:
yield emoji_dict["sheet_x"] yield emoji_dict["sheet_x"]
yield emoji_dict["sheet_y"] yield emoji_dict["sheet_y"]
@ -151,7 +151,7 @@ def generate_sprite_css_files(
emoji_data: List[Dict[str, Any]], emoji_data: List[Dict[str, Any]],
emojiset: str, emojiset: str,
alt_name: str, alt_name: str,
fallback_emoji_data: List[Dict[str, Any]], fallback_emoji_data: Sequence[Dict[str, Any]],
) -> None: ) -> None:
""" """
Spritesheets are usually NxN squares. 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, emojiset: str,
emoji_data: List[Dict[str, Any]], emoji_data: List[Dict[str, Any]],
alt_name: Optional[str] = None, alt_name: Optional[str] = None,
fallback_emoji_data: List[Dict[str, Any]] = list(), fallback_emoji_data: Sequence[Dict[str, Any]] = [],
) -> None: ) -> None:
# `alt_name` is an optional parameter that we use to avoid duplicating below # `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 # code. It is only used while setting up google-blob emoji set as it is just