Improve error message when pulling variables with different roles
Description:
When pulling variables with different roles (inward / outward) at parent level, the error message should clearly indicate the type of conflict. Currently, the error message ambiguously states that the variable already exists, without specifying the conflict.
A suggestion would be to refine the error message to directly indicate the role of the existing variable.
Current behavior:
ValueError: cannot add outward 'a' sys.a already exists
Expected behavior:
ValueError: cannot add outward 'a' sys.a already exists as inward
Naturally, the message should be tailored to fit different contexts.
ValueError: cannot add inward 'a' sys.a already exists as outward
Reproduction
from cosapp.systems import System
class Foo(System):
def setup(self):
self.add_inward('a')
class Bar(System):
def setup(self):
self.add_outward('a')
class Composite(System):
def setup(self):
self.add_child(Foo('foo'), pulling=['a'])
self.add_child(Bar('bar'), pulling=['a'])
sys = Composite('sys')