Make Node a dataclass #5
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: greg/quoracle#5
Loading…
Reference in a new issue
No description provided.
Delete branch "adsharma/dataclass"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Dataclasses make the code more compact and generate many convenience
functions.
This code would not be necessary if we made:
in the dataclass. More instances below.
Ah, I've been targeting Python 3.6, and I think dataclasses are a 3.7+ thing?
Backports are available: https://pypi.org/project/dataclasses/
In general, dataclasses eliminate so much boilerplate code that I use them wherever I can.
Thanks for the PR! I spent some time reading up on dataclasses, and I think the switch here may not be worth it.
capacity
intoNode
which it didn't previously have, and it's not clear whatcapacity
means. For example, if we construct a node likeNode('a', read_capacity=100, write_capacity=200)
, there's not a nice value forcapacity
.Node
is part of theExpr
hierarchy, it feels weird to me thatNode
would be a dataclass but notAnd
orOr
.This should be
__post_init__
.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.