Skip to content

Commit

Permalink
Code style and make tests work with both mypy and pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
cvzi committed May 15, 2024
1 parent 8b9a9d7 commit 305c641
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
10 changes: 4 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import re
from typing import Any, Callable, Dict, List, Tuple, Union
from typing_extensions import Literal
import emoji.unicode_codes
import pytest
from typing import Dict, Any, Tuple, Union
from typing_extensions import Literal
import emoji.unicode_codes
from testutils import ascii, normalize, all_language_packs, all_language_and_alias_packs


Expand Down Expand Up @@ -130,13 +128,13 @@ def remove_variant(s: str) -> str:
english_pack[':admission_tickets:']) + '\ufe0f'

with pytest.raises(ValueError):
emoji.emojize(':admission_tickets:', variant=False) # pyright: ignore [reportArgumentType]
emoji.emojize(':admission_tickets:', variant=False) # type: ignore[arg-type]

with pytest.raises(ValueError):
emoji.emojize(':admission_tickets:', variant=True) # pyright: ignore [reportArgumentType]
emoji.emojize(':admission_tickets:', variant=True) # type: ignore[arg-type]

with pytest.raises(ValueError):
emoji.emojize(':admission_tickets:', variant='wrong') # pyright: ignore [reportArgumentType]
emoji.emojize(':admission_tickets:', variant='wrong') # type: ignore[arg-type]

assert emoji.emojize(":football:") == ':football:'
assert emoji.emojize(":football:", variant="text_type") == ':football:'
Expand Down
6 changes: 3 additions & 3 deletions tests/test_dict.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Unittests for the big dict of dicts containing all emoji"""


from typing import Set, Dict
import re
import emoji


def test_all_languages_list():
"""Compare all language keys in EMOJI_DATA with the emoji.LANGUAGES list"""

langs: set[str] = set()
langs: Set[str] = set()
for item in emoji.EMOJI_DATA.values():
langs.update(item.keys())
all_languages = {lang for lang in langs if len(lang) == 2 and lang.lower() == lang}
Expand All @@ -27,7 +27,7 @@ def test_emoji_versions():

def check_duplicate_names(lang: str):
"""Check that there are no duplicate names in the fully_qualified except for different variants"""
seen = {}
seen: Dict[str, int] = {}
for item in emoji.EMOJI_DATA.values():
if item["status"] > emoji.STATUS["fully_qualified"]:
continue
Expand Down
1 change: 0 additions & 1 deletion tests/test_nfkc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Unittests for canonically equivalent Unicode sequences"""

import emoji

from testutils import is_normalized

def test_database_normalized():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_unicode_codes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Unittests for emoji.unicode_codes."""

from typing import Set
import emoji.unicode_codes
from testutils import get_language_packs

Expand All @@ -25,7 +26,7 @@ def test_compare_normal_and_aliases():
def test_no_alias_duplicates():
# There should not be two emoji with the same alias
# (aliases still can be the same as another 'en'-name)
all_aliases: set[str] = set()
all_aliases: Set[str] = set()
for data in emoji.EMOJI_DATA.values():
if data['status'] <= emoji.STATUS['fully_qualified'] and 'alias' in data:
for alias in data['alias']:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_versions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Unittests for versions in EMOJI_DATA"""

from typing import Any, Dict, List
import emoji.unicode_codes
import pytest
import emoji.unicode_codes
from testutils import all_language_packs

def test_emoji_versions_complete_emojize():
Expand Down

0 comments on commit 305c641

Please sign in to comment.