From c850a006d98b65a61d626de29dc662b6afdd6f08 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 4 Dec 2022 01:59:47 -0800 Subject: [PATCH] emoji: Import modules relative to ZULIP_PATH. Newer mypy is less confused this way. Signed-off-by: Anders Kaseorg --- pyproject.toml | 4 ++-- tools/setup/emoji/build_emoji | 13 ++++++------- tools/setup/emoji/generate_emoji_names | 7 ++++--- tools/setup/emoji/generate_emoji_names_table | 9 ++++++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8ebb35fad8..1614445ef3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ line-length = 100 target-version = ["py38"] [tool.isort] -src_paths = [".", "tools", "tools/setup/emoji"] +src_paths = [".", "tools"] known_third_party = "zulip" profile = "black" line_length = 100 @@ -127,7 +127,7 @@ ignore = [ "N806", # Variable in function should be lowercase ] line-length = 100 -src = [".", "tools", "tools/setup/emoji"] +src = [".", "tools"] target-version = "py38" [tool.ruff.isort] diff --git a/tools/setup/emoji/build_emoji b/tools/setup/emoji/build_emoji index 108ea5fd5a..a9f3be96b2 100755 --- a/tools/setup/emoji/build_emoji +++ b/tools/setup/emoji/build_emoji @@ -9,8 +9,12 @@ from typing import Any, Dict, Iterator, List, Optional, Sequence import orjson -from emoji_names import EMOJI_NAME_MAPS -from emoji_setup_utils import ( +ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../") +sys.path.append(ZULIP_PATH) + +from scripts.lib.zulip_tools import generate_sha1sum_emoji, run_as_root +from tools.setup.emoji.emoji_names import EMOJI_NAME_MAPS +from tools.setup.emoji.emoji_setup_utils import ( EMOTICON_CONVERSIONS, REMAPPED_EMOJIS, emoji_names_for_picker, @@ -21,11 +25,6 @@ from emoji_setup_utils import ( get_emoji_code, ) -ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../") -sys.path.append(ZULIP_PATH) - -from scripts.lib.zulip_tools import generate_sha1sum_emoji, run_as_root - TARGET_EMOJI_DUMP = os.path.join(ZULIP_PATH, "static", "generated", "emoji") TARGET_EMOJI_STYLES = os.path.join(ZULIP_PATH, "static", "generated", "emoji-styles") EMOJI_CACHE_PATH = "/srv/zulip-emoji-cache" diff --git a/tools/setup/emoji/generate_emoji_names b/tools/setup/emoji/generate_emoji_names index 24f9623f36..9b75e924fa 100755 --- a/tools/setup/emoji/generate_emoji_names +++ b/tools/setup/emoji/generate_emoji_names @@ -6,11 +6,12 @@ from collections import defaultdict import orjson -from custom_emoji_names import CUSTOM_EMOJI_NAME_MAPS -from emoji_setup_utils import get_emoji_code - ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../") sys.path.append(ZULIP_PATH) + +from tools.setup.emoji.custom_emoji_names import CUSTOM_EMOJI_NAME_MAPS +from tools.setup.emoji.emoji_setup_utils import get_emoji_code + CLDR_DATA_FILE = os.path.join( ZULIP_PATH, "node_modules", "cldr-annotations-modern", "annotations", "en", "annotations.json" ) diff --git a/tools/setup/emoji/generate_emoji_names_table b/tools/setup/emoji/generate_emoji_names_table index aeaab241f9..8be9fbce95 100755 --- a/tools/setup/emoji/generate_emoji_names_table +++ b/tools/setup/emoji/generate_emoji_names_table @@ -6,15 +6,18 @@ # sources' decisions about what names to provide to each Unicode # codepoint. import os +import sys from typing import Any, Dict, List import orjson -from emoji_names import EMOJI_NAME_MAPS -from emoji_setup_utils import EMOJISETS, emoji_is_universal, get_emoji_code - TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ZULIP_PATH = os.path.dirname(TOOLS_DIR) +sys.path.append(ZULIP_PATH) + +from tools.setup.emoji.emoji_names import EMOJI_NAME_MAPS +from tools.setup.emoji.emoji_setup_utils import EMOJISETS, emoji_is_universal, get_emoji_code + UNIFIED_REACTIONS_FILE = os.path.join( ZULIP_PATH, "zerver", "management", "data", "unified_reactions.json" )