tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Add linting to ensure boundaries of client/server code are respected

Open DiamondJoseph opened this issue 11 months ago • 2 comments

the tiled.server and tiled.client modules are intended to be kept seperate to allow dependencies to be kept minimal in each. However, this is not enforced except by code review which is falliable. Configuring a linting step to ensure that certain packages are not able to import from each other would prevent this happening.

e.g. dodal has configured importlinter to prevent circular imports

[tool.importlinter]
root_package = "dodal"

[[tool.importlinter.contracts]]
name = "Common cannot import from beamlines"
type = "forbidden"
source_modules = ["dodal.common"]
forbidden_modules = ["dodal.beamlines"]

[[tool.importlinter.contracts]]
name = "Enforce import order"
type = "layers"
layers = ["dodal.plans", "dodal.beamlines", "dodal.devices"]

This may also be useful for enforcing optional dependencies are not misused?

DiamondJoseph avatar Jan 24 '25 16:01 DiamondJoseph

The above configures so that dodal.common cannot import from dodal.beamlines, and that dodal.plans can import from dodal.beamlines, which can import from dodal.devices but not in the opposite direction.

DiamondJoseph avatar Jan 24 '25 16:01 DiamondJoseph

Great idea!

danielballan avatar Jan 24 '25 18:01 danielballan