From d44acd42a5206074362ca4f84c033ffc02f958a6 Mon Sep 17 00:00:00 2001 From: Alan Meadows Date: Sat, 3 Oct 2026 14:48:01 -0700 Subject: [PATCH] Replace fuzzywuzzy with thefuzz and drop python-Levenshtein fuzzywuzzy and python-Levenshtein are GPL-licensed. thefuzz is the MIT-licensed successor of fuzzywuzzy and is backed by rapidfuzz (MIT), so it needs no separate Levenshtein extension. Resource.get_operation_group_name now compares the lower-cased operation group name against the lower-cased resource id and breaks ties by length and name. Previously, a tie depended on set iteration order. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e15bfd2f-39e6-4d7f-97ec-4733ad80e9ad --- requirements.txt | 3 +-- src/aaz_dev/swagger/model/specs/_resource.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 82d5bad7..3c5a1d9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ schematics~=2.1.1 pyyaml~=6.0.2 -fuzzywuzzy~=0.18.0 +thefuzz~=0.22.1 pluralizer~=1.2.0 lxml>=5.0.0 flask~=3.0.3 @@ -12,6 +12,5 @@ MarkupSafe>=2.1.5 jsonschema~=4.23.0 click~=8.1.2 setuptools>=78.1.1 -python-Levenshtein azure-mgmt-core azdev diff --git a/src/aaz_dev/swagger/model/specs/_resource.py b/src/aaz_dev/swagger/model/specs/_resource.py index 98a3fc5c..efbce1e4 100644 --- a/src/aaz_dev/swagger/model/specs/_resource.py +++ b/src/aaz_dev/swagger/model/specs/_resource.py @@ -4,7 +4,7 @@ import os import re -from fuzzywuzzy import fuzz +from thefuzz import fuzz from command.model.configuration import CMDResource from ._utils import map_path_2_repo @@ -62,9 +62,11 @@ def get_operation_group_name(self): if len(operation_groups) == 1: return operation_groups.pop() + # use the name which is closest to resource_id. resource_id is lower case, so compare + # case-insensitively, and break ties by length then name so the choice is deterministic. op_group_name = sorted( operation_groups, - key=lambda nm: fuzz.partial_ratio(self.id, nm), # use the name which is closest to resource_id + key=lambda nm: (fuzz.partial_ratio(self.id, nm.lower()), len(nm), nm), reverse=True )[0] setattr(self, "_op_group_name", op_group_name)