From 197fe88307f615c458ac4c4cc2c942a6b6ed7a3e Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 1 Jan 2021 19:54:28 +0100 Subject: [PATCH 1/2] style: use ReturnValue over List --- brownie/network/event.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/brownie/network/event.py b/brownie/network/event.py index 81b5e1568..082a3907d 100644 --- a/brownie/network/event.py +++ b/brownie/network/event.py @@ -10,6 +10,7 @@ from eth_event import EventError from brownie._config import _get_data_folder +from brownie.convert.datatypes import ReturnValue from brownie.convert.normalize import format_event from brownie.exceptions import EventLookupError @@ -166,17 +167,17 @@ def __eq__(self, other: object) -> bool: return other == self._ordered[0] return other == self._ordered - def items(self) -> List: + def items(self) -> ReturnValue: """_EventItem.items() -> a list object providing a view on _EventItem[0]'s items""" - return [(i, self[i]) for i in self.keys()] + return ReturnValue([(i, self[i]) for i in self.keys()]) - def keys(self) -> List: + def keys(self) -> ReturnValue: """_EventItem.keys() -> a list object providing a view on _EventItem[0]'s keys""" - return [i.replace(" (indexed)", "") for i in self._ordered[0].keys()] + return ReturnValue([i.replace(" (indexed)", "") for i in self._ordered[0].keys()]) - def values(self) -> List: + def values(self) -> ReturnValue: """_EventItem.values() -> a list object providing a view on _EventItem[0]'s values""" - return list(self._ordered[0].values()) + return ReturnValue(self._ordered[0].values()) def __get_path() -> Path: From cf8290b2e04eb7a200e51b2d458b67095de6e912 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 1 Jan 2021 20:15:30 +0100 Subject: [PATCH 2/2] feat: allow comparing events to sequences --- brownie/network/event.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brownie/network/event.py b/brownie/network/event.py index 082a3907d..a6fdac7c3 100644 --- a/brownie/network/event.py +++ b/brownie/network/event.py @@ -164,6 +164,9 @@ def __iter__(self) -> Iterator: def __eq__(self, other: object) -> bool: if len(self._ordered) == 1: + if isinstance(other, (tuple, list, ReturnValue)): + # sequences compare directly against the event values + return self._ordered[0].values() == other return other == self._ordered[0] return other == self._ordered