static_site_tests: remove the rapidfuzz dependency
- ID
d7cced9- date
2026-05-09 03:51:46+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
5a2876d- message
static_site_tests: remove the `rapidfuzz` dependency It's useful for high-performance fuzzing or if you need fine-grained control over the algorithm, but I need neither, so let's remove another dependency.- changed files
6 files, 30 additions, 19 deletions
Changed files
CHANGELOG.md (4533) → CHANGELOG.md (4622)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a61425..43514f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+## v37 - 2026-05-09
+
+Remove the `rapidfuzz` dependency from `chives.static_site_tests`.
+
## v36 - 2026-05-05
Fix another dependency issue with `chives.static_site_tests`.
dev_requirements.txt (1281) → dev_requirements.txt (1235)
diff --git a/dev_requirements.txt b/dev_requirements.txt
index 8751a13..21e5b23 100644
--- a/dev_requirements.txt
+++ b/dev_requirements.txt
@@ -43,8 +43,6 @@ pytest-vcr==1.0.2
# via -r dev_requirements.in
pyyaml==6.0.3
# via vcrpy
-rapidfuzz==3.14.3
- # via alexwlchan-chives
ruff==0.15.9
# via -r dev_requirements.in
smartypants==2.0.2
pyproject.toml (1510) → pyproject.toml (1497)
diff --git a/pyproject.toml b/pyproject.toml
index 45135cc..6581b3a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -26,7 +26,7 @@ license = "MIT"
[project.optional-dependencies]
fetch = ["certifi"]
media = ["Pillow"]
-static_site_tests = ["playwright", "pytest", "rapidfuzz"]
+static_site_tests = ["playwright", "pytest"]
text = ["smartypants"]
urls = ["certifi"]
src/chives/__init__.py (391) → src/chives/__init__.py (391)
diff --git a/src/chives/__init__.py b/src/chives/__init__.py
index 237bceb..6a441e1 100644
--- a/src/chives/__init__.py
+++ b/src/chives/__init__.py
@@ -11,4 +11,4 @@ I share across multiple sites.
"""
-__version__ = "36"
+__version__ = "37"
src/chives/static_site_tests.py (9790) → src/chives/static_site_tests.py (9819)
diff --git a/src/chives/static_site_tests.py b/src/chives/static_site_tests.py
index e8430ad..97b5f75 100644
--- a/src/chives/static_site_tests.py
+++ b/src/chives/static_site_tests.py
@@ -6,6 +6,7 @@ from abc import ABC, abstractmethod
import collections
from collections.abc import Iterator
import concurrent.futures
+from difflib import SequenceMatcher
import glob
import itertools
import os
@@ -16,7 +17,6 @@ from typing import TypeVar
from playwright.sync_api import Browser, sync_playwright
import pytest
from _pytest.mark.structures import ParameterSet
-from rapidfuzz import fuzz
from chives.dates import date_matches_any_format, find_all_dates
from chives.media import is_av1_video
@@ -237,7 +237,7 @@ class StaticSiteTestSuite[M](ABC):
Find pairs of similar-looking tags in the collection `tags`.
"""
for t1, t2 in itertools.combinations(sorted(tags), 2):
- if fuzz.ratio(t1, t2) > 80:
+ if SequenceMatcher(None, t1, t2).ratio() > 0.8:
yield (t1, t2)
known_similar_tags: set[tuple[str, str]] = set()
tests/test_static_site_tests.py (10547) → tests/test_static_site_tests.py (10676)
diff --git a/tests/test_static_site_tests.py b/tests/test_static_site_tests.py
index e84181d..a1b9cd8 100644
--- a/tests/test_static_site_tests.py
+++ b/tests/test_static_site_tests.py
@@ -258,27 +258,36 @@ class TestAllTimestampsAreConsistent:
pytester.runpytest("-k", keyword).assert_outcomes(passed=1)
-def test_checks_for_similar_tags(pytester: Pytester) -> None:
+@pytest.mark.parametrize(
+ "tags_in_metadata, known_similar_tags, expected_outcome",
+ [
+ pytest.param({"red", "green", "blue"}, {}, {"passed": 1}, id="distinct_tags"),
+ pytest.param({"red robot", "rod robot"}, {}, {"failed": 1}, id="similar_tags"),
+ pytest.param(
+ {"red robot", "rod robot"},
+ {("red robot", "rod robot")},
+ {"passed": 1},
+ id="similar_tags_marked_known",
+ ),
+ ],
+)
+def test_checks_for_similar_tags(
+ pytester: Pytester,
+ tags_in_metadata: set[str],
+ known_similar_tags: set[tuple[str, str]],
+ expected_outcome: dict[str, int],
+) -> None:
"""
The tests check for similar and misspelt tags.
"""
keyword = "test_no_similar_tags"
- # Check a site with distinct tags.
- create_pyfile(pytester, tags_in_metadata={"red", "green", "blue"})
- pytester.runpytest("-k", keyword).assert_outcomes(passed=1)
-
- # Check a site with similar tags.
- create_pyfile(pytester, tags_in_metadata={"red robot", "rod robot", "rid robot"})
- pytester.runpytest("-k", keyword).assert_outcomes(failed=1)
-
- # Check a site with similar tags, but marked as known-similar.
create_pyfile(
pytester,
- tags_in_metadata={"red robot", "rod robot", "green", "blue"},
- known_similar_tags={("red robot", "rod robot")},
+ tags_in_metadata=tags_in_metadata,
+ known_similar_tags=known_similar_tags,
)
- pytester.runpytest("-k", keyword).assert_outcomes(passed=1)
+ pytester.runpytest("-k", keyword).assert_outcomes(**expected_outcome)
@pytest.mark.skipif(