Skip to content

Commit

Permalink
fix type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
XzzX committed Jan 15, 2025
1 parent d4d8557 commit af4ebc9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyiron_xzzx/generic_storage/hdf5_storage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from dataclasses import is_dataclass
from typing import Any
from typing import Any, Iterator

import h5py

Expand Down Expand Up @@ -30,7 +30,7 @@ class HDF5Group(StorageGroup):
def __init__(self, data: h5py.File):
self.data = data

def __contains__(self, item: object):
def __contains__(self, item: object) -> bool:
return item in self.data

def __delitem__(self, key: str):
Expand Down Expand Up @@ -68,17 +68,18 @@ def __setitem__(self, key: str, value: Any):
group["_type"] = "@".join([module, qualname, version])
unwrap_dataclass(group, value)
return

try:
self.data[key] = value
except TypeError as type_error:
raise TypeError(
f"'{key}' of type {type(value)} cannot be written to HDF5."
) from type_error

def __iter__(self):
def __iter__(self) -> Iterator[str]:
return iter(self.data)

def __len__(self):
def __len__(self) -> int:
return len(self.data)

def create_group(self, key: str) -> HDF5Group:
Expand Down

0 comments on commit af4ebc9

Please sign in to comment.