Skip to content

Commit 178eb0a

Browse files
authored
Merge pull request #48 from DiamondLightSource/copier-update
Update to copier template to 2.1.0-40-g9e70b8b
2 parents db33d03 + b51eaf9 commit 178eb0a

23 files changed

+107
-48
lines changed

.copier-answers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 2.0.2-10-g0eb87d2
2+
_commit: 2.1.0-40-g9e70b8b
33
_src_path: gh:DiamondLightSource/python-copier-template
44
author_email: [email protected]
55
author_name: Gary Yendell

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
4444
// After the container is created, install the python project in editable form
4545
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
46-
}
46+
}

.github/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua
2424

2525
This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.
2626

27-
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.0.2/how-to.html).
27+
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).

.github/ISSUE_TEMPLATE/bug_report.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug Report
3+
about: The template to use for reporting bugs and usability issues
4+
title: " "
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
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).
11+
12+
## Steps To Reproduce
13+
Steps to reproduce the behavior:
14+
1. Go to '...'
15+
2. Click on '....'
16+
3. Scroll down to '....'
17+
4. See error
18+
19+
20+
## Acceptance Criteria
21+
- Specific criteria that will be used to judge if the issue is fixed

.github/ISSUE_TEMPLATE/issue.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Issue
3+
about: The standard template to use for feature requests, design discussions and tasks
4+
title: " "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
A brief description of the issue, including specific stakeholders and the business case where appropriate
11+
12+
## Acceptance Criteria
13+
- Specific criteria that will be used to judge if the issue is fixed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Fixes #ISSUE
2+
3+
### Instructions to reviewer on how to test:
4+
1. Do thing x
5+
2. Confirm thing y happens
6+
7+
### Checks for reviewer
8+
- [ ] Would the PR title make sense to a user on a set of release notes

.github/pages/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
<link rel="canonical" href="main/index.html">
99
</head>
1010

11-
</html>
11+
</html>

.github/workflows/_docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ jobs:
4747
if: github.ref_type == 'tag' || github.ref_name == 'main'
4848
# We pin to the SHA, not the tag, for security reasons.
4949
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
50-
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3
50+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
5151
with:
5252
github_token: ${{ secrets.GITHUB_TOKEN }}
5353
publish_dir: .github/pages
54-
keep_files: true
54+
keep_files: true

.github/workflows/_release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Create GitHub Release
2424
# We pin to the SHA, not the tag, for security reasons.
2525
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
26-
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
26+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
2727
with:
2828
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
2929
files: "*"

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ repos:
55
- id: check-added-large-files
66
- id: check-yaml
77
- id: check-merge-conflict
8+
- id: end-of-file-fixer
89

910
- repo: local
1011
hooks:

.vscode/extensions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"recommendations": [
33
"ms-vscode-remote.remote-containers",
44
]
5-
}
5+
}

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"editor.codeActionsOnSave": {
66
"source.organizeImports": "explicit"
77
},
8+
"files.insertFinalNewline": true,
89
"[python]": {
910
"editor.defaultFormatter": "charliermarsh.ruff",
1011
},
11-
}
12+
}

.vscode/tasks.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"problemMatcher": [],
1414
}
1515
]
16-
}
16+
}

catalog-info.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ metadata:
77
spec:
88
type: documentation
99
lifecycle: experimental
10-
owner: user:mef65357
10+
owner: user:mef65357

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,5 @@
181181
html_show_copyright = False
182182

183183
# Logo
184-
html_logo = "images/fastcs.svg"
185-
html_favicon = "images/fastcs.svg"
184+
html_logo = "images/dls-logo.svg"
185+
html_favicon = html_logo

docs/how-to/contribute.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
```{include} ../../.github/CONTRIBUTING.md
2-
```
2+
```

docs/images/dls-logo.svg

+11
Loading

docs/reference/api.md

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
# API
22

3-
This is the internal API reference for fastcs. The key modules are summarised below.
4-
5-
## Controllers
6-
73
```{eval-rst}
8-
.. automodule:: fastcs.controller
9-
:members:
10-
```
4+
.. automodule:: fastcs
115
12-
## Attributes
13-
14-
```{eval-rst}
15-
.. automodule:: fastcs.attributes
16-
:members:
6+
``fastcs``
7+
-----------------------------------
178
```
189

19-
## Datatypes
10+
This is the internal API reference for fastcs
2011

2112
```{eval-rst}
22-
.. automodule:: fastcs.datatypes
23-
:members:
13+
.. data:: fastcs.__version__
14+
:type: str
15+
16+
Version number as calculated by https://github.com/pypa/setuptools_scm
2417
```

pyproject.toml

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"]
2+
requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
@@ -55,7 +55,7 @@ name = "Martin Gaughran"
5555

5656

5757
[tool.setuptools_scm]
58-
write_to = "src/fastcs/_version.py"
58+
version_file = "src/fastcs/_version.py"
5959

6060
[tool.mypy]
6161
ignore_missing_imports = true # Ignore missing stubs in imported modules
@@ -105,11 +105,18 @@ commands =
105105
src = ["src", "tests"]
106106
line-length = 88
107107
lint.select = [
108-
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
109-
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
110-
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
111-
"F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f
112-
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
113-
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
114-
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
108+
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
109+
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
110+
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
111+
"F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f
112+
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
113+
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
114+
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
115+
"SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self
115116
]
117+
118+
[tool.ruff.lint.per-file-ignores]
119+
# By default, private member access is allowed in tests
120+
# See https://github.com/DiamondLightSource/python-copier-template/issues/154
121+
# Remove this line to forbid private member access in tests
122+
"tests/**/*" = ["SLF001"]

src/fastcs/attributes.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,17 @@ def allowed_values(self) -> list[str] | None:
131131
return self._allowed_values
132132

133133
async def process(self, value: T) -> None:
134-
if self._write_display_callback is not None:
135-
await self._write_display_callback(self._datatype.dtype(value))
136-
137134
await self.process_without_display_update(value)
135+
await self.update_display_without_process(value)
138136

139137
async def process_without_display_update(self, value: T) -> None:
140138
if self._process_callback is not None:
141139
await self._process_callback(self._datatype.dtype(value))
142140

141+
async def update_display_without_process(self, value: T) -> None:
142+
if self._write_display_callback is not None:
143+
await self._write_display_callback(self._datatype.dtype(value))
144+
143145
def set_process_callback(self, callback: AttrCallback[T] | None) -> None:
144146
self._process_callback = callback
145147

src/fastcs/backends/epics/ioc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _get_input_record(pv_name: str, datatype: DataType) -> RecordWrapper:
3333

3434

3535
def _create_and_link_read_pv(pv_name: str, attribute: AttrR) -> None:
36-
record = _get_input_record(pv_name, attribute._datatype)
36+
record = _get_input_record(pv_name, attribute.datatype)
3737

3838
async def async_wrapper(v):
3939
record.set(v)

src/fastcs/backends/tango/dsr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def register_dev(dev_name: str, dev_class: str, dsr_instance: str) -> None:
211211
dsr_name = f"{dev_class}/{dsr_instance}"
212212
dev_info = DbDevInfo()
213213
dev_info.name = dev_name
214-
dev_info._class = dev_class
214+
dev_info._class = dev_class # noqa
215215
dev_info.server = dsr_name
216216

217217
db = Database()

src/fastcs/controller.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ def path(self) -> list[str]:
1717
"""Path prefix of attributes, recursively including parent ``Controller``s."""
1818
return self._path
1919

20+
def set_path(self, path: list[str]):
21+
if self._path:
22+
raise ValueError(f"SubController is already registered under {self.path}")
23+
24+
self._path = path
25+
2026
def _bind_attrs(self) -> None:
2127
for attr_name in dir(self):
2228
attr = getattr(self, attr_name)
@@ -29,13 +35,9 @@ def register_sub_controller(self, name: str, sub_controller: SubController):
2935
raise ValueError(
3036
f"Controller {self} already has a SubController registered as {name}"
3137
)
32-
if sub_controller.path:
33-
raise ValueError(
34-
f"SubController is already registered under {sub_controller.path}"
35-
)
3638

3739
self.__sub_controller_tree[name] = sub_controller
38-
sub_controller._path = self.path + [name]
40+
sub_controller.set_path(self.path + [name])
3941

4042
def get_sub_controllers(self) -> dict[str, BaseController]:
4143
return self.__sub_controller_tree

0 commit comments

Comments
 (0)