-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use dict_factory in store for better readability #487
Conversation
688a4e9
to
25d27f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A handful of minor comments, this is a huge cleanup. I like the idea of using the columns directly from the database to generate the dict, that way if the order does ever change none of the code will have to.
@@ -779,7 +779,7 @@ def toggle_bom_pos(self, *_): | |||
fp = board.FindFootprintByReference(ref) | |||
bom = toggle_exclude_from_bom(fp) | |||
pos = toggle_exclude_from_pos(fp) | |||
self.store.set_bom(ref, bom) | |||
self.store.set_bom(ref, int(bom)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was up with the necessity to cast here but not previously? (No mention in the commit message of the reason why)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember but I guess that sqlite doesn't like to get a "1" for a boolean value. Previously the casting was done in th e set_bom function, in other places it was done like this. So I decided to make the cast always in the same place.
b904539
to
cd001af
Compare
Thanks @chmorgan for the review 👍🏽 |
I always struggled with al those index numbers scatterd all around the code base and for a long time wanted to improve that.
So I started with the store and introduced a row_factory that returns a dict instead of a list which improves readability throughout the code base a lot.
For example
if self.hide_bom_parts and part[6]:
becomes
if self.hide_bom_parts and part["exclude_from_bom"]: