diff --git a/pyproject.toml b/pyproject.toml index 17f1129..a0d71f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,6 @@ dependencies = [ "python-dateutil", "python-slugify", "termcolor>=2.1", - "thefuzz", ] [project.optional-dependencies] tests = [ diff --git a/requirements.txt b/requirements.txt index 906cc0e..1d534e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,3 @@ pytest-cov==4.1.0 python-slugify==8.0.1 respx==0.20.1 termcolor==2.3.0 -thefuzz==0.19.0 diff --git a/src/norwegianblue/__init__.py b/src/norwegianblue/__init__.py index 05d547f..5865f01 100644 --- a/src/norwegianblue/__init__.py +++ b/src/norwegianblue/__init__.py @@ -96,17 +96,13 @@ def norwegianblue( @lru_cache(maxsize=None) def suggest_product(product: str) -> str: - import warnings - - with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=UserWarning) - from thefuzz import process + import difflib # Get all known products from the API or cache all_products = norwegianblue("all").splitlines() # Find the closest match - result = process.extractOne(product, all_products) + result = difflib.get_close_matches(product, all_products, n=1) logging.info("Suggestion:\t%s (score: %d)", *result) return result[0]