mwhittaker / quoracle

A Swiss Army knife for read-write quorum systems
MIT License
84 stars 8 forks source link

Make Node a dataclass #5

Open adsharma opened 3 years ago

adsharma commented 3 years ago

Dataclasses make the code more compact and generate many convenience functions.

mwhittaker commented 3 years ago

Ah, I've been targeting Python 3.6, and I think dataclasses are a 3.7+ thing?

adsharma commented 3 years ago

Backports are available: https://pypi.org/project/dataclasses/

In general, dataclasses eliminate so much boilerplate code that I use them wherever I can.

adsharma commented 3 years ago

Yes - it saves only 10 lines in this diff. Not an earth shattering difference :)

I've addressed the bugs you found in the code and simplified the typing and default values.

I'll leave it here just in case you end up using dataclasses elsewhere and then want to convert this one for consistency.