Closed atomflunder closed 2 years ago
Thanks for reporting. I tried to add the type stubs. However I am unsure why it fails the type stub test for jaro
and jaro_winkler
: https://github.com/maxbachmann/Levenshtein/runs/7311103290?check_suite_focus=true. There should are type hints for them in rapidfuzz
.
I am not quite sure either what the cause of the error might be. Maybe a stupid idea, but does the action maybe download an older version of the packages from pypi? If not, I think we could manually add the stubs to the __init__.pyi
file, like the other functions already in there to please Mypy, however that does sound like a headache to maintain.
Like:
from typing Sequence, Hashable, Callable
...
def distance(
s1: Sequence[Hashable],
s2: Sequence[Hashable],
processor: Optional[Callable] = None,
score_cutoff: Optional[float] = None,
) -> int: ...
def ratio(
s1: Sequence[Hashable],
s2: Sequence[Hashable],
processor: Optional[Callable] = None,
score_cutoff: Optional[float] = None,
) -> float: ...
def hamming(
s1: Sequence[Hashable],
s2: Sequence[Hashable],
processor: Optional[Callable] = None,
score_cutoff: Optional[float] = None,
) -> int: ...
def jaro(
s1: Sequence[Hashable],
s2: Sequence[Hashable],
processor: Optional[Callable] = None,
score_cutoff: Optional[float] = None,
) -> float: ...
def jaro_winkler(
s1: Sequence[Hashable],
s2: Sequence[Hashable],
processor: Optional[Callable] = None,
score_cutoff: Optional[float] = None,
) -> float: ...
Again, probably not the ideal way to go about things. In any case, thanks for responding so quickly.
I am not quite sure either what the cause of the error might be. Maybe a stupid idea, but does the action maybe download an older version of the packages from pypi?
no this appears to be the newest version
If not, I think we could manually add the stubs to the init.pyi file, like the other functions already in there to please Mypy, however that does sound like a headache to maintain.
Since those are not going to change a lot I guess this would be fine. Do you want to open a PR with these stubs?
Yes, I can do that.
This is part of v0.19.2
Hello, I recently tried to upgrade Levenshtein to Version 0.19.1 and I noticed that using some functions will throw an error in the IDE using Pylance or Mypy.
Example using
distance
:The error message:
This is (I think) because the
__init__.pyi
file has stubs for some but not all available functions.From what I can tell these are missing from the stub file:
distance
,ratio
,hamming
,jaro
, andjaro_winkler
.Would it be possible to add those, or are you recommending to just shut up Pylance by adding a
# type: ignore
comment on each line? Would you be open for a pull request to be submitted? Thanks in advance for answering!