Skip to content

Commit

Permalink
enable ruff-pl checks with some exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
XzzX committed Jan 16, 2025
1 parent a975dc7 commit 0961021
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 27 deletions.
31 changes: 15 additions & 16 deletions pyiron_workflow/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
"""
Expand Down
18 changes: 8 additions & 10 deletions pyiron_workflow/nodes/for_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0961021

Please sign in to comment.