Creating abstract transaction_item class? #176
Replies: 2 comments 1 reply
-
Added some code to support this idea in PR 177. I may still have some linting errors, but the idea is there. |
Beta Was this translation helpful? Give feedback.
-
These properties are used to simulate direct read-only access to the value of a given field, so I don't think we want to change its signature: these values are used all over the place in expressions and functions and they have an intuitive use. Returning a class instance instead of a value would have major side effects on the entire code base. However I'm still trying to understand the proposal. What is the advantage of capturing type constraints in a class vs a function call? |
Beta Was this translation helpful? Give feedback.
-
In the abstract_transaction.init there are a bunch of checks for whether some of what I call "transaction_items" (e.g.
unique_id
,timestamp
, etc.) areempty
orunknown
. While writing some updates for PR 134 on the manual csv input plugin, I'm finding it error prone to try to make sure all the things I pass toInTransaction
,OutTransaction
, andIntraTransaction
meet the requirements set by theabstract_transaction.__init__
requirements.Ideally I'd think we could have something similar to the
Keywords
class that can serve as a global reference for what the properties of each of these "transaction_items" should be. So for example, what if instead of returning astr
herewe returned a
Unique_ID
that inherits fromTransaction_Item
that looked something like:Then somewhere else we could define an
Enum
likeKeywords
that defines all the possibletransaction_item_type
s inTransaction_Item_Type
.In this way, in all the input plugins, like the manual csv one, I can ensure all the input parameters to the
InTransaction
,OutTransaction
, andIntraTransaction
conform to the required values ofempty
andunknown
without having to referenceabstract_transaction.py
when writing value checkers like these. I.e. right now, some of them don't get filled with the correct values (e.g. some are filled with__unknown
when they shouldn't be). Rather than essentially rewrite the checks ofabstract_transaction
this would allow me to set the value of all optionaltransaction_items
with the correct value of__unknown
or empty.I think this would reduce the amount of duplicate checks going on like here as well as reduce the amount of work developers would have to do to ensure future plugins provide the correct input parameters to
abstract_transaction.__init__
.One last thing to note, is the need of this becomes a lot more apparent if you checkout my PR 134 where I'm trying to generalize things into
Dict
s rather than have a instance variable name for everytransaction_item_type
as was previously done. This reduces the amount of duplicate code by quite a bit.Beta Was this translation helpful? Give feedback.
All reactions