[ty] Replace strsim with CPython-based Levenshtein implementation by AlexWaygood · Pull Request #23291 · astral-sh/ruff (original) (raw)
added 3 commits
Replace the strsim::damerau_levenshtein dependency with a Levenshtein
implementation ported from CPython's suggestion algorithm. The new
implementation uses case-insensitive character matching with weighted
costs (matching CPython's approach) and improved max-distance heuristics,
rather than the simple Damerau-Levenshtein with lowercased comparison.
This removes the strsim crate dependency from ty_python_semantic.
https://claude.ai/code/session_014vwDhReNbswR4MXhYNcvBW
- Rename
unresolved_membertotypoandmembertocandidatein levenshtein.rs since the module is used for TypedDict key suggestions - Move
pub(crate) use diagnostic::levenshteinto the use-statement section in types.rs - Update .md test files with typos that trigger suggestions under the new Levenshtein algorithm ("nane" -> "name", "leg" -> "legs")
- Add intentional misspellings from test data to _typos.toml allowlist
https://claude.ai/code/session_014vwDhReNbswR4MXhYNcvBW
AlexWaygood changed the title
Replace strsim with CPython-based Levenshtein implementation [ty] Replace strsim with CPython-based Levenshtein implementation
…nostic.rs`
- Move
levenshtein.rsfromtypes::diagnostictodiagnostic(convertingdiagnostic.rstodiagnostic/mod.rs) - Revert all changes to
types/diagnostic.rs: restoredid_you_meanimport and original callsite instead of calling levenshtein directly - Remove the
levenshteinre-export fromtypes.rs - Use
HideUnderscoredSuggestions::Yesindid_you_mean - Update
_typos.tomlexclusion path to match new file location
https://claude.ai/code/session_014vwDhReNbswR4MXhYNcvBW
AlexWaygood changed the title
[ty] Replace strsim with CPython-based Levenshtein implementation [ty] Replace strsim with CPython-based Levenshtein implementation
AlexWaygood deleted the claude/upgrade-levenshtein-impl-tLEYU branch
carljm added a commit that referenced this pull request
- main: (43 commits)
[
ruff] Suppress diagnostic for strings with backslashes in interpolations before Python 3.12 (RUF027) (#21069) [flake8-bugbear] Fix B023 false positive for immediately-invoked lambdas (#23294) [ty] AddFinalmdtests for loops and redeclaration (#23331) [flake8-pyi] Also check string annotations (PYI041) (#19023) Remove AlexWaygood as a flake8-pyi codeowner (#23347) [ty] Add comments to clarify the purpose ofNominalInstanceType::class_nameandNominalInstanceType::class_module_name(#23339) Add attestations for release artifacts and Docker images (#23111) [ty] Fixassert_typediagnostic messages (#23342) [ty] Force-update all insta snapshots (#23343) Add Q004 to the list of conflicting rules (#23340) [ty] Fixinvalid-match-patternfalse positives (#23338) [ty] new diagnostic called-match-pattern-must-be-a-type (#22939) [ty] Update flaky projects (#23337) [ty] Increase timeout for ecosystem report to 40 min (#23336) Bump ecosystem-analyzer pin (#23335) [ty] Replacestrsimwith CPython-based Levenshtein implementation (#23291) [ty] Add mdtest for staticmethod assigned in class body (#23330) [ty] fix inferring type variable from string literal argument (#23326) [ty] bytes literal is a sequence of integers (#23329) Update rand and getrandom (#23333) ...
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
[ Show hidden characters]({{ revealButtonHref }})