Repository navigation
Replace GPL fuzzywuzzy with MIT thefuzz and drop python-Levenshtein - #576
Open
Alan Meadows (alanmeadows) wants to merge 1 commit into
Open
Alan Meadows (alanmeadows) wants to merge 1 commit into
Alan Meadows (alanmeadows) wants to merge 1 commit into
Conversation
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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
fuzzywuzzywiththefuzzand removes thepython-Levenshteinrequirement.fuzzywuzzyandpython-Levenshtein(with itsLevenshteindependency) are GPL-licensed. License-compliance tooling flags them for downstream consumers that installaaz-dev.thefuzzis the renamed, MIT-licensed successor offuzzywuzzyfrom the same maintainers. It is backed byrapidfuzz, which is also MIT, so no separate Levenshtein extension is needed.fuzz.partial_ratioinResource.get_operation_group_nameis the only use.Behaviour
rapidfuzz computes
partial_ratiowith an optimal alignment, while fuzzywuzzy with python-Levenshtein uses a matching-blocks heuristic. A plain import swap therefore changes some operation group choices. To keep the selection stable, the sort key now:nm.lower()against the resource id, which is already lower-cased, so case differences no longer affect the score;(len(nm), nm). Previously a tie picked whichever name came first when iterating aset, which depends on hash randomization.I compared the old and new selection on every path in the stable ARM specs of
azure-rest-api-specs. I used aaz-dev's ownswagger_resource_path_to_resource_idand_parse_operation_group_name, and kept only paths whose operations map to more than one operation group, since only those reachpartial_ratio.thefuzz, unchanged keythefuzz, this PR's keyThe one remaining difference is
Microsoft.ApiManagement/service/{}/apis/{}/issues/{}/comments/{}: it now picksApiIssueCommentoverApiIssuComment, a group name that is misspelled in the spec's operation ids.Testing
pip install -r requirements.txtresolves, and neither fuzzywuzzy nor any Levenshtein package is installed.thefuzz.fuzz, and the spec-wide comparison above was run against the patchedget_operation_group_name.azCLI output for a downstream TypeSpec/Swagger workspace is identical before and after the change.