GothenburgBitFactory / tasklib

A Python library for interacting with taskwarrior databases.
http://tasklib.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
146 stars 27 forks source link

Overload comparison operators for LazyUUIDTaskSet? #96

Closed thehunmonkgroup closed 3 months ago

thehunmonkgroup commented 3 years ago

https://github.com/vit-project/vit/issues/300 exposes a limitation in LazyUUIDTaskSet, namely, that it cannot be used in a standard Python comparison, because of a type mismatch.

It seems reasonable for tasklib to provide some overloaded comparison operators for LazyUUIDtTaskSet, which would do the required loading of the dependencies and convert them to a proper set, so that comparisons work natively.

Looks like it should be pretty straightforward: https://www.tutorialspoint.com/How-to-overload-Python-comparison-operators

Thoughts?

mhalano commented 3 years ago

This bug was treated in the 2.4.0 release?

tbabej commented 3 years ago

@mhalano No, this issue is still pending a fix :slightly_smiling_face: actually something I would consider a good first issue!

@thehunmonkgroup The proposal for making LazyUUIDTaskSet comparable with a regular set of UUIDs sounds good to me.

which would do the required loading of the dependencies, and convert them to a proper set

Unclear if you mean that the laziness would have to be dropped, because I suspect that does not have the be the case.

thehunmonkgroup commented 3 years ago

Unclear if you mean that the laziness would have to be dropped, because I suspect that does not have the be the case.

I don't think it would have to be dropped. If I understand the overloaded comparison operators correctly, the lazy UUIDs could be converting to a proper set in the overloaded method, so lazy UUIDs would only be converted to proper UUIDs when the set is part of a comparison.

tbabej commented 3 years ago

lazy UUIDs would only be converted to proper UUIDs when the set is part of a comparison.

Correct, we're on the same page then. This can even just happen within the operator implementation internally, so no changes to the object itself are needed. Actually a lot of operators are overloaded, it's just that __gt__ and __lt__ are not among them.

mhalano commented 2 years ago

@tbabej The PR made by @RonMcKay didn't close this issue?

thehunmonkgroup commented 3 months ago

Pretty sure this is done.