up-bank-api icon indicating copy to clipboard operation
up-bank-api copied to clipboard

[FR]: Implement comparability of model objects

Open lmartinking opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Yes, I was running the following code:

oldtx = #... list of transactions ...
newtx = get_all_transactions(...)
newtx = [t for t in newtx if t not in oldtx]

And noticed that if you compare two different instances of the same transaction (ie: they are different instances, but representing the same transaction with the same id) they equate to False.

Describe the solution you'd like

Implement __eq__ on transaction objects. Or a more general solution could be on model objects if they have an id field.

Describe alternatives you've considered

As a workaround, I made a set of existing IDs and filter my new transaction list against those.

Additional context

No response

lmartinking avatar Nov 18 '22 12:11 lmartinking

Yeah I'll definitely add this, can't believe I didn't think to add that at the time 👍

jcwillox avatar Nov 18 '22 15:11 jcwillox

Thanks for your prompt response!

I realised one edge case, and that's where tags have been added to a transaction since the initial fetch (eg: via the app). I'm not sure the best way to handle this right now.

lmartinking avatar Nov 19 '22 09:11 lmartinking