From e0e4e345f6a135da051a6a3628c91b56aeb16708 Mon Sep 17 00:00:00 2001 From: layday Date: Tue, 22 Sep 2020 15:09:37 +0300 Subject: [PATCH] Add type annotations `wheel` does not read from MANIFEST.in - the stub and marker files need to also be added as `package_data` in setup.py. --- MANIFEST.in | 2 +- jellyfish/__init__.pyi | 11 +++++++++++ jellyfish/py.typed | 0 setup.py | 7 +++---- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 jellyfish/__init__.pyi create mode 100644 jellyfish/py.typed diff --git a/MANIFEST.in b/MANIFEST.in index c7c6f27..fe2a10e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -include LICENSE *.rst *.py cjellyfish/*.c cjellyfish/*.h docs/* testdata/* +include LICENSE *.rst *.py *.pyi py.typed cjellyfish/*.c cjellyfish/*.h docs/* testdata/* global-exclude .git diff --git a/jellyfish/__init__.pyi b/jellyfish/__init__.pyi new file mode 100644 index 0000000..78a58da --- /dev/null +++ b/jellyfish/__init__.pyi @@ -0,0 +1,11 @@ +def levenshtein_distance(s1: str, s2: str) -> int: ... +def jaro_similarity(s1: str, s2: str) -> float: ... +def jaro_winkler_similarity(s1: str, s2: str, long_tolerance: bool = ...) -> float: ... +def damerau_levenshtein_distance(s1: str, s2: str) -> int: ... +def soundex(s: str) -> str: ... +def hamming_distance(s1: str, s2: str) -> int: ... +def nysiis(s: str) -> str: ... +def match_rating_codex(s: str) -> str: ... +def match_rating_comparison(s1: str, s2: str) -> bool: ... +def metaphone(s: str) -> str: ... +def porter_stem(s: str) -> str: ... diff --git a/jellyfish/py.typed b/jellyfish/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index 34ea30d..24d041e 100755 --- a/setup.py +++ b/setup.py @@ -80,8 +80,6 @@ class TestCommand(Command): def run_setup(build_c): - kw = {} - if build_c: kw = dict( ext_modules=[ @@ -103,10 +101,9 @@ def run_setup(build_c): ) ], cmdclass=dict(build_ext=ve_build_ext, test=TestCommand), - packages=["jellyfish"], ) else: - kw = dict(cmdclass=dict(test=TestCommand), packages=["jellyfish"]) + kw = dict(cmdclass=dict(test=TestCommand)) with open("README.rst") as readme: long_description = readme.read() @@ -135,6 +132,8 @@ def run_setup(build_c): "Programming Language :: Python :: 3.9", "Topic :: Text Processing :: Linguistic", ], + packages=["jellyfish"], + package_data={"jellyfish": ["*.pyi", "py.typed"]}, **kw )