new: import-linter module boundaries (#74)
Domain packages (finance, fitness, maintenance, smart_home) and `bots/`, with contracts: composition root above domains above platform; each domain reachable from others only through its `service` module; `bots/` forbidden from importing `hapi`. `just lint` runs import-linter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
12b634b7e0
commit
a01c785842
13 files changed
+136
-4
No files matched your search
+54
-2
@@ -28,7 +28,7 @@ testpaths = ["tests"]
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
target-version = "py314"
|
||||
src = ["src", "tests"]
|
||||
src = ["src", "tests", "bots"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
@@ -40,7 +40,7 @@ select = [
|
||||
"tests/**" = ["S101", "S603", "PLR2004"]
|
||||
|
||||
[tool.pyright]
|
||||
include = ["src", "tests"]
|
||||
include = ["src", "tests", "bots"]
|
||||
pythonVersion = "3.14"
|
||||
typeCheckingMode = "strict"
|
||||
venvPath = "."
|
||||
@@ -49,9 +49,61 @@ venv = ".venv"
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"httpx>=0.29.0",
|
||||
"import-linter>=2.17",
|
||||
"pyright>=1.1.414",
|
||||
"pytest>=9.2.0",
|
||||
"pytest-asyncio>=1.5.0",
|
||||
"ruff>=0.17.6",
|
||||
"rust-just>=1.59.0",
|
||||
]
|
||||
|
||||
[tool.importlinter]
|
||||
root_packages = ["hapi", "bots"]
|
||||
|
||||
[[tool.importlinter.contracts]]
|
||||
name = "Composition root above domains, domains above platform"
|
||||
type = "layers"
|
||||
containers = ["hapi"]
|
||||
layers = [
|
||||
"app : cli",
|
||||
"finance : fitness : maintenance : smart_home",
|
||||
"platform",
|
||||
]
|
||||
|
||||
[[tool.importlinter.contracts]]
|
||||
name = "Finance is reachable from other domains only through its service"
|
||||
type = "protected"
|
||||
protected_modules = ["hapi.finance"]
|
||||
allowed_importers = ["hapi.app", "hapi.cli"]
|
||||
ignore_imports = ["hapi.** -> hapi.finance.service"]
|
||||
unmatched_ignore_imports_alerting = "none"
|
||||
|
||||
[[tool.importlinter.contracts]]
|
||||
name = "Fitness is reachable from other domains only through its service"
|
||||
type = "protected"
|
||||
protected_modules = ["hapi.fitness"]
|
||||
allowed_importers = ["hapi.app", "hapi.cli"]
|
||||
ignore_imports = ["hapi.** -> hapi.fitness.service"]
|
||||
unmatched_ignore_imports_alerting = "none"
|
||||
|
||||
[[tool.importlinter.contracts]]
|
||||
name = "Maintenance is reachable from other domains only through its service"
|
||||
type = "protected"
|
||||
protected_modules = ["hapi.maintenance"]
|
||||
allowed_importers = ["hapi.app", "hapi.cli"]
|
||||
ignore_imports = ["hapi.** -> hapi.maintenance.service"]
|
||||
unmatched_ignore_imports_alerting = "none"
|
||||
|
||||
[[tool.importlinter.contracts]]
|
||||
name = "Smart home is reachable from other domains only through its service"
|
||||
type = "protected"
|
||||
protected_modules = ["hapi.smart_home"]
|
||||
allowed_importers = ["hapi.app", "hapi.cli"]
|
||||
ignore_imports = ["hapi.** -> hapi.smart_home.service"]
|
||||
unmatched_ignore_imports_alerting = "none"
|
||||
|
||||
[[tool.importlinter.contracts]]
|
||||
name = "Bots talk to hAPI over HTTP only"
|
||||
type = "forbidden"
|
||||
source_modules = ["bots"]
|
||||
forbidden_modules = ["hapi"]
|
||||
Reference in new issue
Block a user