Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ci): use pathlib in check-shadow-tests hook (unbreak pre-commit on main) (#4422)

LearningCircuitec8208dfe6dc
diff --git a/.pre-commit-hooks/check-shadow-tests.py b/.pre-commit-hooks/check-shadow-tests.py
index 5ef4556d23..e01a723628 100755
--- a/.pre-commit-hooks/check-shadow-tests.py
+++ b/.pre-commit-hooks/check-shadow-tests.py
@@ -23,9 +23,9 @@ The reason text is required so the exemption is self-documenting.
"""
import ast
-import os
import re
import sys
+from pathlib import Path
# Marker that exempts a file, mirroring the `# allow: unmarked-sleep`
# convention used by check-unmarked-sleep.py. A trailing reason is required.
@@ -42,9 +42,9 @@ _RESET = "\033[0m" if _USE_COLOR else ""
def is_test_module(path: str) -> bool:
"""True for pytest test modules (not conftest/__init__/helpers)."""
- # os.path.basename handles both / and \ so the hook behaves the same
+ # Path().name handles both / and \ so the hook behaves the same
# if it's ever invoked outside pre-commit (which normalizes to POSIX).
- name = os.path.basename(path)
+ name = Path(path).name
if not name.endswith(".py"):
return False
return name.startswith("test_") or name.endswith("_test.py")
diff --git a/changelog.d/+shadow-tests-hook-pathlib.misc.md b/changelog.d/+shadow-tests-hook-pathlib.misc.md
new file mode 100644
index 0000000000..feb23d2cb5
--- /dev/null
+++ b/changelog.d/+shadow-tests-hook-pathlib.misc.md
@@ -0,0 +1 @@
+CI: fix the freshly-merged ``check-shadow-tests`` pre-commit hook using ``os.path.basename()``, which the repo's own ``check-pathlib-usage`` hook forbids. Because PR pre-commit runs ``--all-files`` against the PR-merged-into-main tree, this one line on main turned every open PR's pre-commit red. Switched to ``pathlib.Path(path).name`` (behaviour verified identical to ``os.path.basename`` across separator/edge cases).