diff --git a/pyiron_workflow/channels.py b/pyiron_workflow/channels.py index 64084eb6..2dccb481 100644 --- a/pyiron_workflow/channels.py +++ b/pyiron_workflow/channels.py @@ -144,23 +144,22 @@ def connect(self, *others: Channel) -> None: # so that connection searches run newest to oldest self.connections.insert(0, other) other.connections.insert(0, self) + elif isinstance(other, self.connection_partner_type): + raise ChannelConnectionError( + f"The channel {other.full_label} ({other.__class__.__name__}" + f") has the correct type " + f"({self.connection_partner_type.__name__}) to connect with " + f"{self.full_label} ({self.__class__.__name__}), but is not " + f"a valid connection. Please check type hints, etc." + f"{other.full_label}.type_hint = {other.type_hint}; " + f"{self.full_label}.type_hint = {self.type_hint}" + ) from None else: - if isinstance(other, self.connection_partner_type): - raise ChannelConnectionError( - f"The channel {other.full_label} ({other.__class__.__name__}" - f") has the correct type " - f"({self.connection_partner_type.__name__}) to connect with " - f"{self.full_label} ({self.__class__.__name__}), but is not " - f"a valid connection. Please check type hints, etc." - f"{other.full_label}.type_hint = {other.type_hint}; " - f"{self.full_label}.type_hint = {self.type_hint}" - ) from None - else: - raise TypeError( - f"Can only connect to {self.connection_partner_type.__name__} " - f"objects, but {self.full_label} ({self.__class__.__name__}) " - f"got {other} ({type(other)})" - ) + raise TypeError( + f"Can only connect to {self.connection_partner_type.__name__} " + f"objects, but {self.full_label} ({self.__class__.__name__}) " + f"got {other} ({type(other)})" + ) def disconnect(self, *others: Channel) -> list[tuple[Channel, Channel]]: """ diff --git a/pyiron_workflow/nodes/for_loop.py b/pyiron_workflow/nodes/for_loop.py index af23faba..0bd05847 100644 --- a/pyiron_workflow/nodes/for_loop.py +++ b/pyiron_workflow/nodes/for_loop.py @@ -112,15 +112,14 @@ def merge(d1, d2): key_index_maps = tuple( zipped_index_map(zipped_index) for zipped_index in zipped_generator() ) + elif nested_keys is None and zipped_keys is None: + raise ValueError( + "At least one of `nested_keys` or `zipped_keys` must be specified." + ) else: - if nested_keys is None and zipped_keys is None: - raise ValueError( - "At least one of `nested_keys` or `zipped_keys` must be specified." - ) - else: - raise ValueError( - "Received keys to iterate over, but all values had length 0." - ) + raise ValueError( + "Received keys to iterate over, but all values had length 0." + ) return key_index_maps @@ -393,8 +392,7 @@ def _build_outputs_preview(cls) -> dict[str, Any]: _default, ) in cls._body_node_class.preview_inputs().items(): if label in cls._zip_on + cls._iter_on: - hint = list if hint is None else list[hint] - preview[label] = hint + preview[label] = list if hint is None else list[hint] for label, hint in cls._body_node_class.preview_outputs().items(): preview[cls.output_column_map[label]] = ( list if hint is None else list[hint] diff --git a/pyproject.toml b/pyproject.toml index 84418dd2..d803ad7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,8 +86,25 @@ select = [ "C4", # eradicate "ERA", + # pylint + "PL", +] +ignore = [ + # ignore line-length violations + "E501", + # Too many arguments in function definition + "PLR0913", + # Magic value used in comparison + "PLR2004", + # Import alias does not rename original package + "PLC0414", + # Too many branches + "PLR0912", + # Too many statements + "PLR0915", + # Too many return statements + "PLR0911", ] -ignore = ["E501"] #ignore line-length violations [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] # Ignore unused imports in init files -- we specify APIs this way