taskwiki
taskwiki copied to clipboard
Viewport parentheses issue since taskwarrior 2.6.0
My primary document with viewports in it that uses Taskwiki has started throwing errors. It may be related to the Taskwarrior 2.6.0 update or possibly something with taskwiki or the python ecosystem also updated around the same time.
The specific problem involves parentheses.
So here's an example markdown that used to work great:
### Today | status.not:completed and status.not:waiting and (due.by:eod or prio:H) | due:today
Now this throws an error that looks like this:
Python error: "Mismatched parentheses in expression"
Error detected while processing function provider#python3#Call:
line 18:
Error invoking 'python_execute' on channel 3 (python3-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/errors.py", line 26, in wrapped_function
original_function(*args, **kwargs)
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/decorators.py", line 10, in wrapped_function
original_function(*args, **kwargs)
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/main.py", line 64, in update_to_tw
c.evaluate_viewports()
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/cache.py", line 247, in evaluate_viewports
port.sync_with_taskwarrior()
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/viewport.py", line 343, in sync_with_taskwarrior
to_add, to_del = self.get_tasks_to_add_and_del()
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/viewport.py", line 317, in get_tasks_to_add_and_del
matching_tasks = self.matching_tasks
File "/Users/redacted/.local/share/nvim/site/pack/packer/start/taskwiki/taskwiki/viewport.py", line 294, in matching_tasks
return set(
File "/usr/local/lib/python3.9/site-packages/tasklib/task.py", line 480, in __iter__
self._result_cache = self._execute()
File "/usr/local/lib/python3.9/site-packages/tasklib/task.py", line 512, in _execute
return self.backend.filter_tasks(self.filter_obj)
File "/usr/local/lib/python3.9/site-packages/tasklib/backends.py", line 317, in filter_tasks
for line in self.execute_command(args):
File "/usr/local/lib/python3.9/site-packages/tasklib/backends.py", line 280, in execute_command
raise TaskWarriorException(error_msg)
tasklib.backends.TaskWarriorException: TASKRC override: /Users/redacted/.taskrc
Configuration override rc.confirmation=no
Configuration override rc.dependency.confirmation=no
Configuration override rc.recurrence.confirmation=no
Configuration override rc.json.array=off
Configuration override rc.bulk=0
Configuration override rc.context=
Mismatched parentheses in expression
Command used: task rc.confirmation=no rc.dependency.confirmation=no rc.recurrence.confirmation=no rc.json.array=off rc.bulk=0 rc.context= -DELETED -PARENT ( status.not:completed and status.not:waiting and (due.by:e
od or prio:H) ) export
If I take the task command that was generated and attempt to run it myself, as long as I escape the parentheses by quoting the entire query, it works great:
task rc.confirmation=no rc.dependency.confirmation=no rc.recurrence.confirmation=no rc.json.array=off rc.bulk=0 rc.context= -DELETED -PARENT '( status.not:completed and status.not:waiting and (due.by:eod or prio:H) )' export
And those parentheses are definitely balanced. The only thing I can do to stop the error is to remove the parens, but of course, the query doesn't give me back what I want then.
I realize I could generate a custom report for the query above since it's generic, but in practice, I also have diary pages which use actual dates for things like this so instead of due.by:eod it's due.by:2021-10-25 or whatever and I don't think I can make that work with a custom report. And regardless, I think parens should be supported in viewports as they have been until recently.
Sorry I'm not a python person or I'd track this down more. I'm using taskwiki HEAD, which is currently #925d8ed. This probably has been happening for a couple of weeks or so.
Thanks for your work on this project. I'm a fan!
I can reproduce this, and will look into this later but as a workaround, putting spaces around the parentheses seems to fix the issue :slightly_smiling_face:
I would never have guessed to try that, but I can confirm that spaces around parens as a workaround puts me back in business! Thanks!
No worries, thanks for the detailed bug report!