GothenburgBitFactory / tasklib

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

Cannot set UDA values using TaskWarrior() instances #126

Closed lyndhurst closed 6 months ago

lyndhurst commented 1 year ago

Trying to modify the value of a UDA modifies the description instead.

Add a UDA in taskrc

uda.level.type = numeric

Add a task

task add 'Some task' level:1

Try to modify the value from a shell

>>> tw = TaskWarrior()
>>> t = tw.tasks.pending().get(id=1)
>>> t
'Some task'
>>> t["level"]
'1.000000'
>>> t["level"] = 2
>>> t
'Some task'
>>> t["level"]
'1.000000'
>>> t.save()
>>> t
'level: 4.0'
>>> t["level"]
'1.000000'
CorentinJ commented 6 months ago

The behavior isn't intuitive and I didn't see it documented on the UDA page (but it's consistent with the cli): the UDA will not be considered as such if uda.<YOUR_UDA_NAME>.type isn't declared. Furthermore, you'll get the same behavior if you have periods in YOUR_UDA_NAME, which is the opposite of what the docs recommend.

$ task add "This is a test" dummy:yes
$ task
ID Age  Project Description                                                                                     Urg
1  -            This is a test dummy:yes                                                                           0
$ task config uda.dummy.type string

$ task add "This is a test" dummy:yes
ID Age  Project Description                                                                                     Urg
1  34s          This is a test dummy:yes                                                                           0
2  2s           This is a test                                                                                     0
lyndhurst commented 6 months ago

Thanks for your input.

This question of mine is a bit old, so I do not remember all the details. Reading my initial post, it seems to me that my UDA type was declared, and was not a string, but numeric. Moreover in my example, I am quoting the description when adding the task, and my problem is more about modifying the UDA value programatically than adding new tasks vi the cli.

Anyway, I am closing the issue because I gave up on it a while ago.