Skip to content

Commit 17f3596

Browse files
author
James Souter
committed
reword some comments and error messages
1 parent b733365 commit 17f3596

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/fastcs/controller.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ async def initialise(self):
4545
pass
4646

4747
async def attribute_initialise(self) -> None:
48-
# Initialise any registered handlers for attributes
48+
"""Register update and send callbacks for attributes on this controller
49+
and all subcontrollers"""
4950
self._add_io_callbacks()
5051

5152
for controller in self.get_sub_controllers().values():
@@ -56,7 +57,6 @@ def _add_io_callbacks(self):
5657
ref = attr.io_ref if attr.has_io_ref() else None
5758
io = self._attribute_ref_io_map.get(type(ref))
5859
if isinstance(attr, AttrW):
59-
# is it on process or write_display?
6060
attr.add_process_callback(self._create_send_callback(io, attr, ref))
6161
if isinstance(attr, AttrR):
6262
attr.add_update_callback(self._create_update_callback(io, attr, ref))
@@ -72,15 +72,14 @@ async def send_callback(value):
7272

7373
async def send_callback(value):
7474
await io.send(attr, value)
75-
# TODO, should we just then call the above send_callback here?
7675

7776
return send_callback
7877

7978
def _create_update_callback(self, io, attr, ref):
8079
if ref is None:
8180

8281
async def error_callback():
83-
raise RuntimeError("Attributes without io_ref can not be updated")
82+
raise RuntimeError("Can't call update on Attributes without an io_ref")
8483

8584
return error_callback
8685
else:

tests/test_attribute.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ class ControllerNoIO(Controller):
8888

8989
with pytest.raises(AssertionError, match="does not have an AttributeIO"):
9090
ControllerNoIO()
91-
# TODO, is it okay that we need to initialise the controller
92-
# before the callbacks get assigned?
91+
9392
await c.initialise()
9493
await c.attribute_initialise()
9594
await c.my_attr.update()
@@ -245,8 +244,8 @@ async def update(self, attr):
245244
# default callbacks are not provided by AttributeIO subclasses
246245

247246
with pytest.raises(
248-
RuntimeError, match="Attributes without io_ref can not be updated"
249-
): # TODO, we need a clearer error message for this
247+
RuntimeError, match="Can't call update on Attributes without an io_ref"
248+
):
250249
await c.no_ref.update()
251250

252251
process_spy = mocker.spy(c.no_ref, "update_display_without_process")

0 commit comments

Comments
 (0)