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 the python package and the config and make the contracts kept #669

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
with:
python-version: ${{ inputs.python-version }}
pip-install: ".[dev]"

- name: Run tests
run: tox -e tests

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
runs-on: ["ubuntu-latest", "windows-latest"] # can add macos-latest
python-version: ["3.10","3.11"] # 3.12 should be added when p4p is updated
python-version: ["3.10", "3.11"] # 3.12 should be added when p4p is updated
include:
# Include one that runs in the dev environment
- runs-on: "ubuntu-latest"
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ repos:
entry: ruff format --force-exclude
types: [python]
require_serial: true

- id: import-contracts
name: Ensure import directionality
pass_filenames: false
language: system
entry: lint-imports
types: [python]
require_serial: false
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dev = [
"inflection",
"ipython",
"ipywidgets",
"import-linter",
"matplotlib",
"myst-parser",
"numpydoc",
Expand Down Expand Up @@ -164,3 +165,53 @@ lint.preview = true # so that preview mode PLC2701 is enabled
# See https://github.com/DiamondLightSource/python-copier-template/issues/154
# Remove this line to forbid private member access in tests
"tests/**/*" = ["SLF001"]


[tool.importlinter]
root_package = "ophyd_async"

[[tool.importlinter.contracts]]
name = "Core is independent"
type = "independence"
modules = "ophyd_async.core"

[[tool.importlinter.contracts]]
name = "Epics depends only on core"
type = "forbidden"
source_modules = "ophyd_async.epics"
forbidden_modules = [
"ophyd_async.fastcs",
"ophyd_async.plan_stubs",
"ophyd_async.sim",
"ophyd_async.tango",
]

[[tool.importlinter.contracts]]
name = "tango depends only on core"
type = "forbidden"
source_modules = "ophyd_async.tango"
forbidden_modules = [
"ophyd_async.epics",
"ophyd_async.fastcs",
"ophyd_async.plan_stubs",
"ophyd_async.sim",
]


[[tool.importlinter.contracts]]
name = "sim depends only on core"
type = "forbidden"
source_modules = "ophyd_async.sim"
forbidden_modules = [
"ophyd_async.epics",
"ophyd_async.fastcs",
"ophyd_async.plan_stubs",
"ophyd_async.tango",
]


[[tool.importlinter.contracts]]
name = "Fastcs depends only on core, epics, tango"
type = "forbidden"
source_modules = "ophyd_async.fastcs"
forbidden_modules = ["ophyd_async.plan_stubs", "ophyd_async.sim"]
Loading