Skip to content

Commit

Permalink
Run mypy on src/aiida/orm/nodes/caching.py (#6703)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas authored Jan 14, 2025
1 parent 2da3f96 commit 199a027
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ repos:
src/aiida/orm/comments.py|
src/aiida/orm/computers.py|
src/aiida/orm/implementation/storage_backend.py|
src/aiida/orm/nodes/caching.py|
src/aiida/orm/nodes/comments.py|
src/aiida/orm/nodes/data/array/bands.py|
src/aiida/orm/nodes/data/array/trajectory.py|
Expand Down
10 changes: 3 additions & 7 deletions src/aiida/orm/nodes/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def _compute_hash(self, ignore_errors: bool = True, **kwargs: t.Any) -> str | No
self._node.logger.exception('Node hashing failed')
return None

def _get_objects_to_hash(self) -> list[t.Any]:
def _get_objects_to_hash(self) -> dict[str, t.Any]:
warn_deprecation(
'`NodeCaching._get_objects_to_hash` is deprecated, use `NodeCaching.get_objects_to_hash` instead', version=3
)
return self.get_objects_to_hash()

def get_objects_to_hash(self) -> list[t.Any]:
def get_objects_to_hash(self) -> dict[str, t.Any]:
"""Return a list of objects which should be included in the hash."""

return {
Expand Down Expand Up @@ -158,11 +158,7 @@ def _iter_all_same_nodes(self, allow_before_store=False) -> t.Iterator['Node']:
builder = QueryBuilder(backend=self._node.backend)
builder.append(self._node.__class__, filters={f'extras.{self._HASH_EXTRA_KEY}': node_hash}, subclassing=False)

return (
node
for (node,) in builder.iterall()
if node.base.caching.is_valid_cache # type: ignore[misc,union-attr]
)
return (node for (node,) in builder.iterall() if node.base.caching.is_valid_cache)

@property
def is_valid_cache(self) -> bool:
Expand Down

0 comments on commit 199a027

Please sign in to comment.