Skip to content

Commit efae957

Browse files
committed
Guard LongBridge against legacy US equity profile keys
1 parent 07b2faa commit efae957

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
6+
REPO_ROOT = Path(__file__).resolve().parents[1]
7+
LEGACY_PROFILE_KEYS = (
8+
"hybrid_growth_income",
9+
"semiconductor_rotation_income",
10+
"tech_pullback_cash_buffer",
11+
)
12+
ALLOWED_PATHS = ['tests/test_profile_key_governance.py']
13+
14+
15+
def _iter_repo_files():
16+
for path in sorted(REPO_ROOT.rglob("*")):
17+
if not path.is_file():
18+
continue
19+
if any(part in {".git", ".venv", "__pycache__", ".pytest_cache", ".ruff_cache"} for part in path.parts):
20+
continue
21+
rel = path.relative_to(REPO_ROOT).as_posix()
22+
if rel.startswith("research/results/"):
23+
continue
24+
yield path, rel
25+
26+
27+
def test_legacy_profile_keys_only_exist_in_explicit_rejection_tests():
28+
offenders: dict[str, tuple[str, ...]] = {}
29+
for path, rel in _iter_repo_files():
30+
text = path.read_text(encoding="utf-8", errors="ignore")
31+
hits = tuple(key for key in LEGACY_PROFILE_KEYS if key in text)
32+
if hits and rel not in ALLOWED_PATHS:
33+
offenders[rel] = hits
34+
assert offenders == {}

0 commit comments

Comments
 (0)