Forbid layer imports in the root package
CI / checks (pull_request) Successful in 45s

The layers contract does not check chemenu/__init__.py itself, so an import
there would load a layer for every importer without any check failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
torbenandClaude Opus 5.5 committed 2026-12-02 21:49:48 +01:00
1 parent fcdce6d63b
commit f2882511f4
3 files changed
+20 -1

No files matched your search

+10
View File
@@ -97,6 +97,16 @@ def test_type_checking_import_fails(project: Path) -> None:
assert "chemenu.domain is not allowed to import chemenu.adapters:" in result.stdout
@pytest.mark.parametrize("imported", [*PACKAGES, "evals.model"])
def test_root_package_import_fails(project: Path, imported: str) -> None:
(project / "chemenu" / "__init__.py").write_text(
f"import chemenu.{imported}\n", encoding="utf-8"
)
result = run_lint(project)
assert result.returncode == 1, result.stdout + result.stderr
assert f"chemenu is not allowed to import chemenu.{imported}:" in result.stdout
def test_undeclared_package_fails(project: Path) -> None:
steps = project / "chemenu" / "steps"
steps.mkdir()