diff --git a/.copier-answers.yml b/.copier-answers.yml index b9792e19..88c6c912 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: 2.1.0 +_commit: 2.2.0 _src_path: gh:DiamondLightSource/python-copier-template author_email: gary.yendell@diamond.ac.uk author_name: Gary Yendell diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 79b85ff4..d3d639a5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -43,4 +43,4 @@ "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", // After the container is created, install the python project in editable form "postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install" -} \ No newline at end of file +} diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fdb377e2..4237afc9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects. -For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.1.0/how-to.html). +For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.2.0/how-to.html). diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..aa65892f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,21 @@ +--- +name: Bug Report +about: The template to use for reporting bugs and usability issues +title: " " +labels: 'bug' +assignees: '' + +--- + +Describe the bug, including a clear and concise description of the expected behavior, the actual behavior and the context in which you encountered it (ideally include details of your environment). + +## Steps To Reproduce +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + + +## Acceptance Criteria +- Specific criteria that will be used to judge if the issue is fixed diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md new file mode 100644 index 00000000..52c84dd8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue.md @@ -0,0 +1,13 @@ +--- +name: Issue +about: The standard template to use for feature requests, design discussions and tasks +title: " " +labels: '' +assignees: '' + +--- + +A brief description of the issue, including specific stakeholders and the business case where appropriate + +## Acceptance Criteria +- Specific criteria that will be used to judge if the issue is fixed diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 00000000..8200afe5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,8 @@ +Fixes #ISSUE + +### Instructions to reviewer on how to test: +1. Do thing x +2. Confirm thing y happens + +### Checks for reviewer +- [ ] Would the PR title make sense to a user on a set of release notes diff --git a/.github/pages/index.html b/.github/pages/index.html index 80f0a009..c495f39f 100644 --- a/.github/pages/index.html +++ b/.github/pages/index.html @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/.github/workflows/_docs.yml b/.github/workflows/_docs.yml index 40446e33..a1cafcae 100644 --- a/.github/workflows/_docs.yml +++ b/.github/workflows/_docs.yml @@ -47,8 +47,8 @@ jobs: if: github.ref_type == 'tag' || github.ref_name == 'main' # We pin to the SHA, not the tag, for security reasons. # https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions - uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3 + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: .github/pages - keep_files: true \ No newline at end of file + keep_files: true diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml index e55efdb3..10d8ed87 100644 --- a/.github/workflows/_release.yml +++ b/.github/workflows/_release.yml @@ -23,7 +23,7 @@ jobs: - name: Create GitHub Release # We pin to the SHA, not the tag, for security reasons. # https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions - uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4 + uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 with: prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }} files: "*" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a4cbf7b..60fc23f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ repos: - id: check-added-large-files - id: check-yaml - id: check-merge-conflict + - id: end-of-file-fixer - repo: local hooks: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 66ad6324..933c580c 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,4 +2,4 @@ "recommendations": [ "ms-vscode-remote.remote-containers", ] -} \ No newline at end of file +} diff --git a/.vscode/launch.json b/.vscode/launch.json index c328de06..38e864b0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -416,4 +416,4 @@ ], }, ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index c129d991..101c75fa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,7 +5,8 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, + "files.insertFinalNewline": true, "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", }, -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 946e69d4..c999e864 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,4 +13,4 @@ "problemMatcher": [], } ] -} \ No newline at end of file +} diff --git a/catalog-info.yaml b/catalog-info.yaml index 43505a06..6126145b 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -5,6 +5,6 @@ metadata: title: pvi description: EPICS PV Interface described in YAML spec: - type: documentation + type: library lifecycle: experimental - owner: mef65357 \ No newline at end of file + owner: mef65357 diff --git a/docs/how-to/contribute.md b/docs/how-to/contribute.md index f9c4ca1d..6e419797 100644 --- a/docs/how-to/contribute.md +++ b/docs/how-to/contribute.md @@ -1,2 +1,2 @@ ```{include} ../../.github/CONTRIBUTING.md -``` \ No newline at end of file +``` diff --git a/docs/images/dls-logo.svg b/docs/images/dls-logo.svg index 0af1a177..4fcaa861 100644 --- a/docs/images/dls-logo.svg +++ b/docs/images/dls-logo.svg @@ -1,11 +1,11 @@ - - - - - - - - - - \ No newline at end of file + + + + + + + + + + diff --git a/docs/tutorials/create-pvi-device.md b/docs/tutorials/create-pvi-device.md index 2c7d34ab..dd917b6d 100644 --- a/docs/tutorials/create-pvi-device.md +++ b/docs/tutorials/create-pvi-device.md @@ -44,4 +44,4 @@ pvi reconvert simDetector.pvi.device.yaml simDetector.template simDetectorExtras :::{note} See `pvi reconvert --help` for a full list of options. -::: \ No newline at end of file +::: diff --git a/pyproject.toml b/pyproject.toml index f451179a..1cf28577 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools>=64", "setuptools_scm[toml]>=8"] build-backend = "setuptools.build_meta" [project] @@ -62,7 +62,7 @@ pvi = "pvi.__main__:app" GitHub = "https://github.com/epics-containers/pvi" [tool.setuptools_scm] -write_to = "src/pvi/_version.py" +version_file = "src/pvi/_version.py" [tool.pyright] reportMissingImports = false # Ignore missing stubs in imported modules @@ -113,11 +113,18 @@ commands = src = ["src", "tests"] line-length = 88 lint.select = [ - "B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b - "C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 - "E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e - "F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f - "W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w - "I", # isort - https://docs.astral.sh/ruff/rules/#isort-i - "UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up + "B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b + "C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 + "E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e + "F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f + "W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w + "I", # isort - https://docs.astral.sh/ruff/rules/#isort-i + "UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up + "SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self ] + +[tool.ruff.lint.per-file-ignores] +# By default, private member access is allowed in tests +# See https://github.com/DiamondLightSource/python-copier-template/issues/154 +# Remove this line to forbid private member access in tests +"tests/**/*" = ["SLF001"] diff --git a/schemas/pvi.device.schema.json b/schemas/pvi.device.schema.json index 1eaebad9..cf3abbbd 100644 --- a/schemas/pvi.device.schema.json +++ b/schemas/pvi.device.schema.json @@ -1230,4 +1230,4 @@ ], "title": "Device", "type": "object" -} \ No newline at end of file +} diff --git a/schemas/pvi.formatter.schema.json b/schemas/pvi.formatter.schema.json index bb753b44..8a8ae71d 100644 --- a/schemas/pvi.formatter.schema.json +++ b/schemas/pvi.formatter.schema.json @@ -113,4 +113,4 @@ "$ref": "#/$defs/DLSFormatter" } ] -} \ No newline at end of file +} diff --git a/src/pvi/__main__.py b/src/pvi/__main__.py index bdb1ead3..017c82da 100644 --- a/src/pvi/__main__.py +++ b/src/pvi/__main__.py @@ -58,7 +58,7 @@ def schema( typer.echo(f"Don't know how to create {output.name}") raise typer.Exit(code=1) - output.write_text(json.dumps(schema, indent=2)) + output.write_text(json.dumps(schema, indent=2) + "\n") @app.command() diff --git a/src/pvi/_format/base.py b/src/pvi/_format/base.py index 04967770..55db2988 100644 --- a/src/pvi/_format/base.py +++ b/src/pvi/_format/base.py @@ -56,7 +56,7 @@ def create_schema(cls) -> dict[str, Any]: Formatter itself is not included, as it should not be instanstiated directly. """ - cls._rebuild_child_models() + cls.rebuild_child_models() return cls.type_adapter().json_schema() def format(self, device: Device, path: Path) -> None: diff --git a/src/pvi/_format/dls.edl b/src/pvi/_format/dls.edl index 0b998ea0..5262dcd5 100644 --- a/src/pvi/_format/dls.edl +++ b/src/pvi/_format/dls.edl @@ -338,4 +338,3 @@ indicatorPv "None" font "arial-bold-r-14.0" orientation "horizontal" endObjectProperties - diff --git a/src/pvi/_format/pvi.template.jinja b/src/pvi/_format/pvi.template.jinja index 100def0e..c89be36d 100644 --- a/src/pvi/_format/pvi.template.jinja +++ b/src/pvi/_format/pvi.template.jinja @@ -13,4 +13,3 @@ record("*", "{{ record.pv }}") { } {% endfor %} ### End of PV Interface for {{ device }} ### - diff --git a/src/pvi/_format/template.py b/src/pvi/_format/template.py index 67839d41..88ebda97 100644 --- a/src/pvi/_format/template.py +++ b/src/pvi/_format/template.py @@ -44,4 +44,4 @@ def format_template(device: Device, pv_prefix: str, output: Path): template_txt = Template(template.read()).render( device=device.label, pv_prefix=pv_prefix, records=records ) - expanded.write(template_txt) + expanded.write(template_txt + "\n") diff --git a/src/pvi/typed_model.py b/src/pvi/typed_model.py index b72475a1..1c022b20 100644 --- a/src/pvi/typed_model.py +++ b/src/pvi/typed_model.py @@ -69,16 +69,16 @@ def model_json_schema( ): """Ensure all child models have type field added before generating schema.""" if not cls.models_typed: - TypedModel._rebuild_child_models() + TypedModel.rebuild_child_models() return super().model_json_schema(by_alias, ref_template, schema_generator, mode) @classmethod - def _rebuild_child_models(cls): + def rebuild_child_models(cls): """Recursively rebuild all subclass models to add type into core schema.""" for subclass in cls.__subclasses__(): subclass.model_rebuild(force=True) - subclass._rebuild_child_models() + subclass.rebuild_child_models() @classmethod def _tag(cls): diff --git a/tests/format/input/dls.bob.pvi.formatter.yaml b/tests/format/input/dls.bob.pvi.formatter.yaml index 0f798f90..5987609d 100644 --- a/tests/format/input/dls.bob.pvi.formatter.yaml +++ b/tests/format/input/dls.bob.pvi.formatter.yaml @@ -6,4 +6,4 @@ title_height: 26 max_height: 900 label_width: 120 widget_width: 120 -widget_height: 20 \ No newline at end of file +widget_height: 20 diff --git a/tests/format/input/dls.edl.pvi.formatter.yaml b/tests/format/input/dls.edl.pvi.formatter.yaml index aad28897..cbd4cf4f 100644 --- a/tests/format/input/dls.edl.pvi.formatter.yaml +++ b/tests/format/input/dls.edl.pvi.formatter.yaml @@ -1,2 +1,2 @@ # yaml-language-server: $schema=../../../schemas/pvi.formatter.schema.json -type: DLSFormatter \ No newline at end of file +type: DLSFormatter