Skip to content

Commit

Permalink
add error reporting in dataclass_from_flat_list
Browse files Browse the repository at this point in the history
  • Loading branch information
glucauze committed Aug 14, 2023
1 parent 0a9d992 commit 17db6ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/faceswaplab_utils/ui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def dataclass_from_flat_list(cls: type, values: Tuple[Any, ...]) -> Any:
init_values[field.name] = field.type(*inner_values)
idx += len(inner_values)
else:
if idx >= len(values):
raise IndexError(
f"Expected more values for dataclass {cls}. Current index: {idx}, values length: {len(values)}"
)
value = values[idx]
init_values[field.name] = value
idx += 1
Expand Down

0 comments on commit 17db6ea

Please sign in to comment.