"""nisse-core is what every agent is built on (Part L): it never imports an agent.""" import ast from pathlib import Path import nisse_core AGENTS = ("nisse_dev", "nisse_ops", "nisse_review") def test_core_imports_no_agent() -> None: root = Path(nisse_core.__file__).parent found = [] for path in sorted(root.rglob("*.py")): for node in ast.walk(ast.parse(path.read_text())): if isinstance(node, ast.Import): names = [a.name for a in node.names] elif isinstance(node, ast.ImportFrom): names = [node.module or ""] else: continue found += [f"{path.name}: {n}" for n in names if n.split(".")[0] in AGENTS] assert len(list(root.rglob("*.py"))) > 10 # the modules really are here assert found == []