Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Oct 22, 2024
1 parent 361cb52 commit 1f75ea0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/ophyd_async/core/_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ def set_name(self, name: str):
_setup_child(self, child_name, child)

def __setattr__(self, name: str, value: Any) -> None:
if name != "parent" and isinstance(value, Device):
if name == "parent":
if self.parent not in (value, None):
raise TypeError(
f"Cannot set the parent of {self} to be {value}: "
f"it is already a child of {self.parent}"
)
elif isinstance(value, Device):
_setup_child(self, name, value)
return super().__setattr__(name, value)

Expand Down
6 changes: 5 additions & 1 deletion src/ophyd_async/core/_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ def _callback(self, reading: Reading[SignalDatatypeT]):
for function, want_value in self._listeners.items():
self._notify(function, want_value)

def _notify(self, function: Callback, want_value: bool):
def _notify(
self,
function: Callback[dict[str, Reading[SignalDatatypeT]] | SignalDatatypeT],
want_value: bool,
):
assert self._reading, "Monitor not working"
if want_value:
function(self._reading["value"])
Expand Down
3 changes: 3 additions & 0 deletions src/ophyd_async/core/_soft_signal_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@


class SoftConverter(Generic[SignalDatatypeT]):
# This is Any -> SignalDatatypeT because we support coercing
# value types to SignalDatatype to allow people to do things like
# SignalRW[Enum].set("enum value")
@abstractmethod
def write_value(self, value: Any) -> SignalDatatypeT: ...

Expand Down

0 comments on commit 1f75ea0

Please sign in to comment.