Answer architecture round 1: 4 🔴, 5 🟡 (0 misread); one-way plan packages with a plan core and an Atlassian client, one parse and print of an item's cells, a pure chunk-start decision, a settings table, one plan read and one standing per pick, one config load in chunk-pr, notifier backends in notifier, and the bin regroup filed as item 392

This commit is contained in:
2026-11-16 14:47:46 +01:00
parent 3f7d85c48e
commit f58250d0ce
103 changed files with 1299 additions and 1044 deletions
+45
View File
@@ -0,0 +1,45 @@
import ast
import graphlib
import pathlib
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from repo_checks import ROOT
def package_imports(bin_folder: pathlib.Path) -> dict[str, set[str]]:
"""Each package under bin_folder, with the other packages its modules import, tests aside. A deferred import inside a function counts: it only hides a cycle."""
packages = {init.parent.name for init in bin_folder.glob("*/__init__.py")}
imported: dict[str, set[str]] = {package: set() for package in packages}
for package in packages:
for module in (bin_folder / package).rglob("*.py"):
if module.name.startswith("test_"):
continue
for node in ast.walk(ast.parse(module.read_text(encoding="utf-8"))):
names = [alias.name for alias in node.names] if isinstance(node, ast.Import) else [node.module or ""] if isinstance(node, ast.ImportFrom) and node.level == 0 else []
imported[package].update(top for name in names if (top := name.split(".")[0]) in packages and top != package)
return imported
def cycle(imported: dict[str, set[str]]) -> list[str]:
"""One cycle among the packages, as the packages along it; empty where there is none."""
try:
graphlib.TopologicalSorter(imported).prepare()
except graphlib.CycleError as found:
return list(found.args[1])
return []
class PackageCycles(unittest.TestCase):
def test_no_package_under_bin_imports_one_that_imports_it_back(self):
self.assertEqual(cycle(package_imports(ROOT / "bin")), [], "move what both packages need into a package that imports neither")
def test_a_cycle_through_a_deferred_import_is_found(self):
self.assertEqual(sorted(cycle({"a": {"b"}, "b": {"a"}})[:2]), ["a", "b"])
self.assertEqual(cycle({"a": {"b"}, "b": set()}), [])
if __name__ == "__main__":
unittest.main()