From 324aad307f1af7e050ef8f66887e43a3c66f3e04 Mon Sep 17 00:00:00 2001 From: Sherjeel Shabih Date: Mon, 9 Dec 2024 19:19:43 +0100 Subject: [PATCH] Fixes __len__ of TreeResult when only comparing un-nested types --- deepdiff/model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepdiff/model.py b/deepdiff/model.py index 2373195..9304976 100644 --- a/deepdiff/model.py +++ b/deepdiff/model.py @@ -41,7 +41,7 @@ def remove_empty_keys(self): Remove empty keys from this object. Should always be called after the result is final. :return: """ - empty_keys = [k for k, v in self.items() if not v] + empty_keys = [k for k, v in self.items() if not isinstance(v, (int)) and not v] for k in empty_keys: del self[k] @@ -88,7 +88,7 @@ def __getitem__(self, item): return self.get(item) def __len__(self): - return sum([len(i) for i in self.values() if isinstance(i, SetOrdered)]) + return sum([len(i) for i in self.values() if isinstance(i, SetOrdered)]) + len([i for i in self.values() if isinstance(i, int)]) class TextResult(ResultDict):