Skip to content

Commit

Permalink
ORM: Sealable.seal() return self instead of None
Browse files Browse the repository at this point in the history
The `Sealable` mixin is used by the `ProcessNode` which allows it to be
sealed. By having the `seal` method return `self`, which will be the
`ProcessNode` instance, it brings the behavior on par with the `store`
method.
  • Loading branch information
sphuber committed Oct 14, 2023
1 parent b6f7ec1 commit 16e3bd3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aiida/orm/utils/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,13 @@ def is_sealed(self) -> bool:
"""Returns whether the node is sealed, i.e. whether the sealed attribute has been set to True."""
return self.base.attributes.get(self.SEALED_KEY, False) # type: ignore[attr-defined]

def seal(self) -> None:
def seal(self) -> 'Sealable':
"""Seal the node by setting the sealed attribute to True."""
if not self.is_sealed:
self.base.attributes.set(self.SEALED_KEY, True) # type: ignore[attr-defined]

return self

@override
def _check_mutability_attributes(self, keys: list[str] | None = None) -> None: # pylint: disable=unused-argument
"""Check if the entity is mutable and raise an exception if not.
Expand Down

0 comments on commit 16e3bd3

Please sign in to comment.