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

Raw filters don't seem to be working as intended #113

Open yohannd1 opened 2 years ago

yohannd1 commented 2 years ago

Let's say I have a task folder in ~/_sample_data. The output of unset TASKRC; task rc.data.location=~/_sample_data is (removing the "configuration override" notes):

ID Age  Tag   Description  Urg
 2 5min habit another task  0.8
 1 5min       sample task     0

2 tasks

I then tried to use it this way:

from tasklib import TaskWarrior
import os

del os.environ["TASKRC"] # just to be sure it isn't my config's fault
tw = TaskWarrior(f"{os.environ['HOME']}/_sample_data")

print(tw.tasks.filter("status:pending")) # yields the two tasks
print(tw.tasks.filter("status:pending +habit")) # yields no task (was supposed to yield one)
print(tw.tasks.filter("+habit")) # yields one task, as expected
print(tw.tasks.filter(status="pending", tag="habit")) # yields one task ~ this one works fine as well

The shown output is then:

[sample task, another task]
[]
[another task]
[another task]

But what was expected:

[sample task, another task]
[another task]
[another task]
[another task]

It seems like only raw filters that have more than one condition are affected by this.

yohannd1 commented 2 years ago

After some debugging I've noticed that the command that fails (the second one) is being called as so:

['task', 'rc.confirmation=no', 'rc.dependency.confirmation=no', 'rc.recurrence.confirmation=no', 'rc.json.array=off', 'rc.bulk=0', 'rc.data.location=/home/yohanan/_sample_data', 'status:pending +habit', 'export']

I've went and tried this command out and noticed that sending the whole "status:pending +habit" as a single argument doesn't seem to work on taskwarrior, instead requiring each condition to be a whole different argument or the entire single argument to be wrapped by parenthesis. So: task status:pending +habit and task "(status:pending +habit)" both work but task "status:pending +habit" doesn't. I'm not sure how this should be tackled on tasklib (maybe it has been tackled before but something went wrong). Since task "(status:pending +habit)" works fine, maybe we could just add parenthesis if the query has parenthesis? I'm not sure if that solves the problem completely.