rapidfuzz / RapidFuzz

Rapid fuzzy string matching in Python using various string metrics
https://rapidfuzz.github.io/RapidFuzz/
MIT License
2.61k stars 116 forks source link

Incorrect type hinting in extract #380

Closed Vioshim closed 4 months ago

Vioshim commented 4 months ago

in the recent update of the type hinting due to the lack of =WRatio in the extract procesor arguments, it leads to inconsistent behavior

Example:

from dataclasses import dataclass
from rapidfuzz import process

@dataclass(unsafe_hash=True)
class Foo:
    name: str

items: list[Foo] = [Foo("Test")]
check = {x: x.name for x in items}

result = process.extract("Test", check, limit=1, score_cutoff=60.0)
# No overloads for "extract" match the provided arguments
# Argument types: (str, dict[Foo, str], Literal[1], float)

assert result == [('Test', 100.0, Foo(name='Test'))]
maxbachmann commented 4 months ago

I forgot to add the limit argument to some overloads. https://github.com/rapidfuzz/RapidFuzz/commit/9e5694280ebf2e0e73739270250cb05f5f5ca5e9 should fix this problem