Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DiamondJoseph opened this issue Jan 24, 2025 · 2 comments · May be fixed by #896
Open

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

DiamondJoseph opened this issue Jan 24, 2025 · 2 comments · May be fixed by #896

Comments

@DiamondJoseph
Copy link
Contributor

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
Copy link
Contributor Author

DiamondJoseph commented Jan 24, 2025

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.

@danielballan
Copy link
Member

Great idea!

@DiamondJoseph DiamondJoseph linked a pull request Feb 20, 2025 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants