Private
Public Access
0
0

artifacts

This commit is contained in:
2026-06-29 18:33:50 -04:00
parent d4116f19cc
commit 2852785134
2 changed files with 69 additions and 0 deletions
@@ -0,0 +1,40 @@
"""Refined Phase 4 VC checks per spec metadata.json."""
import re
import sys
from pathlib import Path
src_root = Path("src")
test_artifact_hits = []
ini_file_hits = []
# VC_no_production_path_to_test_fixtures: the literal string "tests/artifacts"
# in source code (not in comments). The spec marks the prior false positive at
# src/commands.py:371 (the line we just removed). Allow comments.
def _is_comment(line: str) -> bool:
s = line.strip()
if s.startswith("#"):
return True
return False
for py_file in src_root.rglob("*.py"):
try:
text = py_file.read_text(encoding="utf-8", errors="replace")
except OSError:
continue
for line_no, line in enumerate(text.splitlines(), 1):
if "tests/artifacts" in line and not _is_comment(line):
test_artifact_hits.append((py_file, line_no, line.strip()))
# VC_no_configs_in_src: any file with .ini extension inside src/.
for ini_file in src_root.rglob("*.ini"):
ini_file_hits.append(ini_file)
print(f"VC_no_production_path_to_test_fixtures:")
print(f" code-line hits: {len(test_artifact_hits)}")
for p, line_no, line in test_artifact_hits[:5]:
print(f" {p}:{line_no}: {line}")
print(f"VC_no_configs_in_src:")
print(f" .ini files in src/: {len(ini_file_hits)}")
for p in ini_file_hits[:5]:
print(f" {p}")
sys.exit(0 if (not test_artifact_hits and not ini_file_hits) else 1)
@@ -0,0 +1,29 @@
"""Banned patterns audit on changed files."""
import re
from pathlib import Path
files = [
"src/layouts.py",
"src/commands.py",
"src/gui_2.py",
"src/paths.py",
"tests/test_default_layout_install.py",
"tests/test_reset_layout.py",
]
patterns = [
("dict[str, Any]", r'dict\[str, Any\]'),
("bare Any param", r': Any[)\\, ]'),
("Optional[T] ret", r'-> Optional'),
("hasattr(x, str)", r"hasattr\(\w+, '\\x27"),
(".get('key', ..)", r"\.get\('\w"),
]
for f in files:
try:
text = Path(f).read_text(encoding="utf-8", errors="replace")
except OSError as e:
print(f"{f}: open error {e}")
continue
counts = {label: len(re.findall(pat, text)) for label, pat in patterns}
print(f"{f}: " + ", ".join(f"{k}={v}" for k, v in counts.items()))