Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix faulty comparisons #579

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/push-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install mypy
run: pip install mypy
- name: Test
run: mypy --ignore-missing-imports ${{ github.event.repository.name }}
run: mypy --ignore-missing-imports --strict-equality ${{ github.event.repository.name }}

ruff-check:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion pyiron_workflow/mixin/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _set_parent(self, new_parent: ParentType | None):
self._parent.remove_child(self)
self._parent = new_parent
self._detached_parent_path = None
if self._parent is not None and self not in self._parent.children:
if self._parent is not None:
self._parent.add_child(self)

@property
Expand Down
25 changes: 9 additions & 16 deletions pyiron_workflow/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,15 @@ def available_backends(
"""

standard_backends = {"pickle": PickleStorage}

def yield_requested():
if isinstance(backend, str):
yield standard_backends[backend]()
elif isinstance(backend, StorageInterface):
yield backend

if backend is not None:
yield from yield_requested()
backend_instance = (
standard_backends.get(backend, PickleStorage)()
if isinstance(backend, str)
else backend
)

if backend_instance is not None:
yield backend_instance
if only_requested:
return

for key, value in standard_backends.items():
if (
backend is None
or (isinstance(backend, str) and key != backend)
or (isinstance(backend, StorageInterface) and value != backend)
):
yield value()
yield from (v() for k, v in standard_backends.items() if k != backend)
2 changes: 1 addition & 1 deletion tests/unit/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_failure_recovery(self):
msg="Expect a recovery file to be saved on failure",
)

reloaded = ANode(label="failing", autoload=True)
reloaded = ANode(label="failing")
self.assertIs(
reloaded.inputs.x.value,
NOT_DATA,
Expand Down
27 changes: 18 additions & 9 deletions tests/unit/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ def test_specific_backend(self):
self.assertIsInstance(backends[0], PickleStorage)

def test_extra_backend(self):
my_interface = PickleStorage()
backends = list(available_backends(my_interface))
self.assertEqual(
len(backends), 2, msg="We expect both the one we passed, and all defaults"
)
self.assertIs(backends[0], my_interface)
self.assertIsNot(
backends[0], backends[1], msg="They should be separate instances"
)
with self.subTest("String backend"):
backends = list(available_backends("pickle"))
print(backends)
self.assertEqual(len(backends), 1, msg="We expect only the defaults")
self.assertIsInstance(backends[0], PickleStorage)

with self.subTest("Object backend"):
my_interface = PickleStorage()
backends = list(available_backends(my_interface))
self.assertEqual(
len(backends),
2,
msg="We expect both the one we passed, and all defaults",
)
self.assertIs(backends[0], my_interface)
self.assertIsNot(
backends[0], backends[1], msg="They should be separate instances"
)

def test_exclusive_backend(self):
my_interface = PickleStorage()
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_type_hinting.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_hint_comparisons(self):

def test_get_type_hints(self):
for hint, origin in [
(int | float, type(int| float)),
(int | float, type(int | float)),
(typing.Annotated[int | float, "foo"], type(int | float)),
(int, None),
(typing.Annotated[int, "foo"], None),
Expand All @@ -129,6 +129,5 @@ def test_get_type_hints(self):
self.assertEqual(_get_type_hints(hint)[0], origin)



if __name__ == "__main__":
unittest.main()
Loading