Summary
walk() recursively sanitizes nested data structures (dicts, lists, strings). The current 14 tests cover dicts, lists, and strings well, but there are no tests for tuples, sets, or mixed nested containers.
What to do
Add a TestWalkContainerTypes class to tests/test_walk.py:
- Tuple with hostile string —
walk(("hello", "n\u0430vi")) — document whether tuples are traversed or passed through
- Set with hostile string —
walk({"hello", "n\u0430vi"}) — document behavior
- Deeply nested mixed —
walk({"a": [("b", "\u0430")]}) — dict containing list containing tuple
- Frozen containers —
walk({"key": frozenset(["n\u0430vi"])})
- Original not mutated — verify
walk() deep-copies and doesn't modify input for all container types
The goal is to document and test the current behavior, even if some types pass through unsanitized. If you find that tuples/sets should be traversed, note it in the PR for discussion.
Files
tests/test_walk.py — add new test class
Hints
- Read
src/navi_sanitize/_pipeline.py for the walk() implementation
walk() uses deepcopy — original data is never modified
- Cyrillic
\u0430 (а) is a good test char — it maps to Latin a
- Run tests with:
uv run pytest tests/test_walk.py -v --benchmark-disable
Summary
walk()recursively sanitizes nested data structures (dicts, lists, strings). The current 14 tests cover dicts, lists, and strings well, but there are no tests for tuples, sets, or mixed nested containers.What to do
Add a
TestWalkContainerTypesclass totests/test_walk.py:walk(("hello", "n\u0430vi"))— document whether tuples are traversed or passed throughwalk({"hello", "n\u0430vi"})— document behaviorwalk({"a": [("b", "\u0430")]})— dict containing list containing tuplewalk({"key": frozenset(["n\u0430vi"])})walk()deep-copies and doesn't modify input for all container typesThe goal is to document and test the current behavior, even if some types pass through unsanitized. If you find that tuples/sets should be traversed, note it in the PR for discussion.
Files
tests/test_walk.py— add new test classHints
src/navi_sanitize/_pipeline.pyfor thewalk()implementationwalk()usesdeepcopy— original data is never modified\u0430(а) is a good test char — it maps to Latinauv run pytest tests/test_walk.py -v --benchmark-disable