Skip to content

Commit

Permalink
Refactor: use dataclasses to discover the date fields in dictionary c…
Browse files Browse the repository at this point in the history
…onversion #2714
  • Loading branch information
iamleeg committed Jun 29, 2022
1 parent 3ec879b commit 01fe1cf
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def to_dict(self):

@classmethod
def date_fields(cls) -> list[str]:
"""Record where dates are kept because they sometimes need special treatment.
A subclass could override this method to indicate it stores additional date fields."""
return ["confirmationDate"]
"""Record where dates are kept because they sometimes need special treatment."""
return [f.name for f in dataclasses.fields(cls) if f.type == datetime.date]


# Actually we want to capture extra fields which can be specified dynamically:
Expand Down

0 comments on commit 01fe1cf

Please sign in to comment.