Skip to content

Commit 52004d2

Browse files
committed
fix: false positive on swapped words
Surfaced false positives in this check with some recent upload testing. Since the permutations can reconstruct the project name to the same as the input, verify that the reconstructed name differs from input. Signed-off-by: Mike Fiedler <[email protected]>
1 parent 43a5219 commit 52004d2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tests/unit/packaging/test_typosnyper.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
("dateutil-python", ("swapped_words", "python-dateutil")),
3030
("numpi", ("common_typos", "numpy")),
3131
("requestz", ("common_typos", "requests")),
32+
("python-dateutil", None), # Pass, swapped_words same as original
3233
],
3334
)
3435
def test_typo_check_name(name, expected):

warehouse/packaging/typosnyper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def _swapped_words(project_name: str, corpus: set[str]) -> TypoCheckMatch:
381381
# Join the words using `-` to create a new name
382382
reconstructed = "-".join(p)
383383
# If the new name is in the list of popular names, return it
384-
if reconstructed in corpus:
384+
if reconstructed != project_name and reconstructed in corpus:
385385
return "swapped_words", reconstructed
386386

387387
return None

0 commit comments

Comments
 (0)