Open pipermerriam opened 5 years ago
We could also just force it on the user to add a @dataclass
decorator on the events. I opened an PR to demonstrate this with the examples: https://github.com/ethereum/lahja/pull/139
dataclasses could be a nice way to do this but I'm not inclined to force it.
but I'm not inclined to force it.
It would be totally up to the consumer to decide to use them or not. Here's a PR to show case that for Trinity https://github.com/ethereum/trinity/pull/726 I only converted a few places there but I happily convert all of them if you are :+1: on that change.
What is wrong
Defining new events requires un-necessary boilerplate. Events are typically purely for data transfer and rarely have extra methods or properties.
How can it be fixed?
It'd be really nice to be able to do this:
Doing this with metaclasses is quite easy and it would reduce the boilerplate in defining new events significantly.