Skip to content

Commit

Permalink
refactor: tidy codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Mar 23, 2024
1 parent af1cb05 commit 1f9b000
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions plugin/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import sublime

assert __package__

PACKAGE_NAME = __package__.partition(".")[0]

DB_FILE_IN_PACKAGE = f"Packages/{PACKAGE_NAME}/data/emoji-test.txt"
Expand Down
10 changes: 5 additions & 5 deletions plugin/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def from_dict(cls, db: dict[str, Any]) -> EmojiDatabase:
def from_lines(cls, lines: Iterable[str]) -> EmojiDatabase:
collection = cls()
for line in lines:
if e := Emoji.from_line(line):
collection.emojis.append(e)
if emoji := Emoji.from_line(line):
collection.emojis.append(emoji)
continue
if m := cls._re_version.fullmatch(line):
collection.version = m.group("version").strip()
Expand All @@ -179,11 +179,11 @@ def from_lines(cls, lines: Iterable[str]) -> EmojiDatabase:
continue
return collection

def to_json(self, *, pretty: bool = False) -> str:
def to_json(self, *, pretty: bool = False, **kwargs: Any) -> str:
if pretty:
kwargs: dict[str, Any] = {"indent": "\t"}
kwargs["indent"] = "\t"
else:
kwargs = {"separators": (",", ":")}
kwargs["separators"] = (",", ":")
return json.dumps(
dict(asdict(self), generator_revision=DB_GENERATOR_REVISION),
ensure_ascii=False,
Expand Down

0 comments on commit 1f9b000

Please sign in to comment.