Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hints #166

Merged
merged 4 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions emoji/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from .core import (
demojize as demojize,
distinct_emoji_list as distinct_emoji_list,
emoji_count as emoji_count,
emoji_list as emoji_list,
emojize as emojize,
is_emoji as is_emoji,
replace_emoji as replace_emoji,
version as version,
)
from .unicode_codes import EMOJI_DATA, LANGUAGES, STATUS

__all__ = [
"emojize",
"demojize",
"emoji_count",
"emoji_list",
"distinct_emoji_list",
"replace_emoji",
"version",
"is_emoji",
"EMOJI_DATA",
"STATUS",
"LANGUAGES",
]
__version__: str
__author__: str
__email__: str
__source__: str
__license__: str
35 changes: 35 additions & 0 deletions emoji/core.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from collections.abc import Callable
from typing_extensions import Literal, TypedDict

_DEFAULT_DELIMITER: str

class _EmojiLisReturn(TypedDict):
emoji: str
location: int

class _EmojiListReturn(TypedDict):
emoji: str
match_start: int
match_end: int

def emojize(
string: str,
delimiters: tuple[str, str] = ...,
variant: Literal["text_type", "emoji_type", None] = ...,
language: str = ...,
version: float | None = ...,
handle_version: str | Callable[[str, dict[str, str]], str] | None = ...,
) -> str: ...
def demojize(
string: str,
delimiters: tuple[str, str] = ...,
language: str = ...,
version: float | None = ...,
handle_version: str | Callable[[str, dict[str, str]], str] | None = ...,
) -> str: ...
def replace_emoji(string: str, replace: str | Callable[[str, dict[str, str]], str] = ..., version: float = ...) -> str: ...
def emoji_list(string: str) -> list[_EmojiListReturn]: ...
def distinct_emoji_list(string: str) -> list[str]: ...
def emoji_count(string: str, unique: bool = ...) -> int: ...
def version(string: str) -> float: ...
def is_emoji(string: str) -> bool: ...
Empty file added emoji/py.typed
Empty file.
6 changes: 6 additions & 0 deletions emoji/unicode_codes/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .data_dict import *

__all__ = ["get_emoji_unicode_dict", "get_aliases_unicode_dict", "EMOJI_DATA", "STATUS", "LANGUAGES"]

def get_emoji_unicode_dict(lang: str) -> dict[str, str]: ...
def get_aliases_unicode_dict() -> dict[str, str]: ...
7 changes: 7 additions & 0 deletions emoji/unicode_codes/data_dict.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from typing import Any

__all__ = ["EMOJI_DATA", "STATUS", "LANGUAGES"]

STATUS: dict[str, int]
LANGUAGES: list[str]
EMOJI_DATA: dict[str, dict[str, Any]]
Empty file added emoji/unicode_codes/py.typed
Empty file.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Multimedia :: Graphics :: Presentation',
'Topic :: Software Development :: Libraries :: Python Modules',
'Typing :: Typed'
],
description="Emoji for Python",
keywords=['emoji'],
Expand Down