From 8cad6afb077236424a149d12dc5aad32dafa80fa Mon Sep 17 00:00:00 2001 From: dangotbanned <125183946+dangotbanned@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:36:59 +0100 Subject: [PATCH] feat: Add repr for `Then` No longer inherited --- altair/vegalite/v5/api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/altair/vegalite/v5/api.py b/altair/vegalite/v5/api.py index 888470507..80ba0bd6b 100644 --- a/altair/vegalite/v5/api.py +++ b/altair/vegalite/v5/api.py @@ -1084,6 +1084,17 @@ def to_dict(self, *args: Any, **kwds: Any) -> _Conditional[_C]: def __deepcopy__(self, memo: Any) -> Self: return type(self)(_Conditional(condition=_deepcopy(self.condition, memo))) + def __repr__(self) -> str: + name = type(self).__name__ + COND = "condition: " + LB, RB = "{", "}" + if len(self.condition) == 1: + args = f"{COND}{self.condition!r}".replace("\n", "\n ") + else: + conds = "\n ".join(f"{c!r}" for c in self.condition) + args = f"{COND}[\n " f"{conds}\n ]" + return f"{name}({LB}\n {args}\n{RB})" + class ChainedWhen(_BaseWhen): """