Skip to content

Commit 868cac0

Browse files
Replaced edit distance with NLTK package
1 parent 2474d10 commit 868cac0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies = [
4949
"setuptools>=65.5.1",
5050
"typer>=0.12.1",
5151
"typing-extensions>=4.7.1",
52-
"python-levenshtein>=0.25.1",
52+
"nltk>=3.9",
5353
]
5454
license = "MIT"
5555
license-files = ["LICENSES/*"]

safety/tool/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from tempfile import mkstemp
99

1010
import typer
11-
from Levenshtein import distance
11+
import nltk
1212
from filelock import FileLock
1313
from rich.padding import Padding
1414
from rich.prompt import Prompt
@@ -227,7 +227,7 @@ def __check_typosquatting(self, package_name):
227227

228228
for pkg in MOST_FREQUENTLY_DOWNLOADED_PYPI_PACKAGES:
229229
if (abs(len(pkg) - len(package_name)) <= max_edit_distance
230-
and distance(pkg, package_name) <= max_edit_distance):
230+
and nltk.edit_distance(pkg, package_name) <= max_edit_distance):
231231
return (False, pkg)
232232

233233
return (True, package_name)

0 commit comments

Comments
 (0)