From 1fbb47f398698baea63cef9bc806ac80bc3e5367 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Tue, 21 Jan 2025 14:08:09 -0800 Subject: [PATCH 1/3] Fix value receiver hinting Signed-off-by: liamhuber --- pyiron_workflow/channels.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyiron_workflow/channels.py b/pyiron_workflow/channels.py index 310e4df1..86159b2e 100644 --- a/pyiron_workflow/channels.py +++ b/pyiron_workflow/channels.py @@ -372,7 +372,7 @@ def __init__( self.strict_hints = strict_hints self.default = default self.value = default # Implicitly type check your default by assignment - self.value_receiver: ReceiverType = value_receiver + self.value_receiver = value_receiver @property def value(self): @@ -399,7 +399,7 @@ def _type_check_new_value(self, new_value): ) @property - def value_receiver(self) -> Self | None: + def value_receiver(self) -> ReceiverType | None: """ Another data channel of the same type to whom new values are always pushed (without type checking of any sort, not even when forming the couple!) From 24655678f02c22c2a9c4afa293036114bb3de3c5 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Wed, 22 Jan 2025 10:00:26 -0800 Subject: [PATCH 2/3] Update setter hint Signed-off-by: liamhuber --- pyiron_workflow/channels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiron_workflow/channels.py b/pyiron_workflow/channels.py index 86159b2e..6f293de6 100644 --- a/pyiron_workflow/channels.py +++ b/pyiron_workflow/channels.py @@ -410,7 +410,7 @@ def value_receiver(self) -> ReceiverType | None: return self._value_receiver @value_receiver.setter - def value_receiver(self, new_partner: Self | None): + def value_receiver(self, new_partner: ReceiverType | None): if new_partner is not None: if not isinstance(new_partner, self.__class__): raise TypeError( From b6d346881d9ce7ec3517c15320e45553d97cdba8 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Wed, 22 Jan 2025 10:02:36 -0800 Subject: [PATCH 3/3] Update docstrings Signed-off-by: liamhuber --- pyiron_workflow/channels.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyiron_workflow/channels.py b/pyiron_workflow/channels.py index 6f293de6..75e5f3e3 100644 --- a/pyiron_workflow/channels.py +++ b/pyiron_workflow/channels.py @@ -296,8 +296,9 @@ class DataChannel(FlavorChannel["DataChannel"], typing.Generic[ReceiverType], AB more specific than the input channel. In addition to connections, these channels can have a single partner - (:attr:`value_receiver: DataChannel`) that is of the _same_ class and obeys type - hints as though it were the "downstream" (input) partner in a connection. + (:attr:`value_receiver`) that is of the same data flavor and the same direction + (i.e. input or output) and obeys type hints as though it were the "downstream" + (input) partner in a connection. Channels with such partners pass any data updates they receive directly to this partner (via the :attr:`value` setter). (This is helpful for passing data between scopes, where we want input at one scope @@ -351,9 +352,9 @@ class DataChannel(FlavorChannel["DataChannel"], typing.Generic[ReceiverType], AB when this channel is a value receiver. This can potentially be expensive, so consider deactivating strict hints everywhere for production runs. (Default is True, raise exceptions when type hints get violated.) - value_receiver (pyiron_workflow.compatibility.Self|None): Another channel of - the same class whose value will always get updated when this channel's - value gets updated. + value_receiver (ReceiverType|None): Another channel of the receiver type (i.e. + also a data flavor and matching input/output type) whose value will always + get updated when this channel's value gets updated. """ def __init__(