add __repr__ methods for catala types

This commit is contained in:
Romain PRIMET 2022-04-21 22:23:24 +02:00
parent 75f1ea3d5e
commit 5367ef65b7

View File

@ -178,6 +178,9 @@ class Money:
def __str__(self) -> str:
return "${:.2}".format(self.value.value / 100)
def __repr__(self) -> str:
return f"Money({self.value.__repr__()})"
class Date:
def __init__(self, value: datetime.date) -> None:
@ -216,6 +219,9 @@ class Date:
def __str__(self) -> str:
return self.value.__str__()
def __repr__(self) -> str:
return f"Date({self.value.__repr__()})"
class Duration:
def __init__(self, value: dateutil.relativedelta.relativedelta) -> None:
@ -277,6 +283,9 @@ class Duration:
def __str__(self) -> str:
return self.value.__str__()
def __repr__(self) -> str:
return f"Duration({self.value.__repr__()})"
class Unit:
def __init__(self) -> None:
@ -297,6 +306,9 @@ class Unit:
def __str__(self) -> str:
return "()"
def __repr__(self) -> str:
return "Unit()"
class SourcePosition:
def __init__(self,