Skip to content

Commit

Permalink
Handle non-method cases in to_dict conversion (huggingface#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
justHungryMan authored May 7, 2024
1 parent 22c739e commit 8805e13
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/datatrove/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __repr__(self):
return ", ".join(f"{key}: {stats}" for key, stats in self.items())

def to_dict(self):
return {a: b.to_dict() for a, b in self.items()}
return {a: (b.to_dict() if hasattr(b, "to_dict") else b) for a, b in self.items()}


class Stats:
Expand Down

0 comments on commit 8805e13

Please sign in to comment.