File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import ast
2+ from pathlib import Path
3+
4+
5+ MANAGERS_DIR = Path (__file__ ).resolve ().parents [1 ] / "hyperbrowser" / "client" / "managers"
6+
7+
8+ def _manager_python_files () -> list [Path ]:
9+ return sorted (
10+ path
11+ for path in MANAGERS_DIR .rglob ("*.py" )
12+ if path .name not in {"serialization_utils.py" , "__init__.py" }
13+ )
14+
15+
16+ def test_manager_modules_use_shared_serialization_helper_only ():
17+ offending_calls : list [str ] = []
18+
19+ for path in _manager_python_files ():
20+ source = path .read_text (encoding = "utf-8" )
21+ module = ast .parse (source , filename = str (path ))
22+ for node in ast .walk (module ):
23+ if not isinstance (node , ast .Call ):
24+ continue
25+ if not isinstance (node .func , ast .Attribute ):
26+ continue
27+ if node .func .attr != "model_dump" :
28+ continue
29+ offending_calls .append (f"{ path .relative_to (MANAGERS_DIR )} :{ node .lineno } " )
30+
31+ assert offending_calls == []
You can’t perform that action at this time.
0 commit comments