From 3bfc61e9f45df99d2ae70d91a46616022430c2e7 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 27 Feb 2023 12:54:49 +0300 Subject: [PATCH] Add __repr__ to data types of Record, Enum and IList --- funml/data/enum.py | 3 +++ funml/data/lists.py | 4 ++++ funml/data/records.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/funml/data/enum.py b/funml/data/enum.py index 3e66a16..f3731e9 100644 --- a/funml/data/enum.py +++ b/funml/data/enum.py @@ -229,6 +229,9 @@ def __str__(self): """Generates a readable presentation of the enum.""" return f"<{self.name}: {self.value}>" + def __repr__(self): + return f"<{self.name}: {self.value}>" + def _get_enum_captured_value(instance: Enum): """Gets the captured value for a given enum instance""" diff --git a/funml/data/lists.py b/funml/data/lists.py index f297e23..90f4395 100644 --- a/funml/data/lists.py +++ b/funml/data/lists.py @@ -345,6 +345,10 @@ def __str__(self): map_to_str = imap(str) return f"[{', '.join(map_to_str(self))}]" + def __repr__(self): + map_to_str = imap(str) + return f"IList({', '.join(map_to_str(self))})" + Q = TypeVar("Q") diff --git a/funml/data/records.py b/funml/data/records.py index 38f3a55..3aa2068 100644 --- a/funml/data/records.py +++ b/funml/data/records.py @@ -278,6 +278,9 @@ def __str__(self): """A readable representation of this type.""" return f"{self.__attrs}" + def __repr__(self): + return f"{self.__class__.__name__}{self.__attrs}" + def __iter__(self): return ((k, v) for k, v in self.__attrs.items())