Skip to content

Commit 57fa60f

Browse files
committed
Pass description as positional argument.
Similarly to #134, passing description via description:{description} doesn't appear to be documented and can lead to problems. See GothenburgBitFactory/bugwarrior#733 and consider the following scenario: ```sh $ task --version 2.5.1 $ task add description:"depends filter does not work with ID" The expression could not be evaluated. $ task add "depends filter does not work with ID" Created task 1. ``` I've tried variations of the previous with various quoting and shells and have gotten the same result.
1 parent 5931171 commit 57fa60f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

taskw/test/test_utils.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ def test_ordering(self):
106106

107107
def test_taskwarrior_null_encoding_bug_workaround(self):
108108
task = {
109+
'description': 'arbitrary description',
109110
'priority': ''
110111
}
111-
actual_encoded = encode_task_experimental(task)[0]
112+
actual_encoded = encode_task_experimental(task)[1]
112113
expected_encoded = "priority:"
113114

114115
eq_(
@@ -119,12 +120,14 @@ def test_taskwarrior_null_encoding_bug_workaround(self):
119120
def test_encodes_dates(self):
120121
arbitrary_date = datetime.date(2014, 3, 2)
121122
task = {
123+
'description': 'arbitrary description',
122124
'arbitrary_field': arbitrary_date
123125
}
124126

125127
actual_encoded_task = encode_task_experimental(task)
126128
expected_encoded_task = encode_task_experimental(
127129
{
130+
'description': 'arbitrary description',
128131
'arbitrary_field': arbitrary_date.strftime(DATE_FORMAT)
129132
}
130133
)
@@ -137,12 +140,14 @@ def test_encodes_dates(self):
137140
def test_encodes_naive_datetimes(self):
138141
arbitrary_naive_datetime = datetime.datetime.now()
139142
task = {
143+
'description': 'arbitrary description',
140144
'arbitrary_field': arbitrary_naive_datetime
141145
}
142146

143147
actual_encoded_task = encode_task_experimental(task)
144148
expected_encoded_task = encode_task_experimental(
145149
{
150+
'description': 'arbitrary description',
146151
'arbitrary_field': (
147152
arbitrary_naive_datetime
148153
.replace(tzinfo=dateutil.tz.tzlocal())
@@ -162,12 +167,14 @@ def test_encodes_zoned_datetimes(self):
162167
tzinfo=arbitrary_timezone
163168
)
164169
task = {
170+
'description': 'arbitrary description',
165171
'arbitrary_field': arbitrary_zoned_datetime
166172
}
167173

168174
actual_encoded_task = encode_task_experimental(task)
169175
expected_encoded_task = encode_task_experimental(
170176
{
177+
'description': 'arbitrary description',
171178
'arbitrary_field': (
172179
arbitrary_zoned_datetime
173180
.astimezone(pytz.utc).strftime(DATE_FORMAT)

taskw/test/test_warrior.py

+10
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@ def test_add_task_null_char(self):
3737
tasks = self.taskwarrior.load_tasks()
3838
assert len(tasks['pending']) == 1
3939
assert tasks['pending'][0]['description'] == 'foobar'
40+
41+
def test_add_task_depends_keyword(self):
42+
"""Add a task with description beginning with keyword "depends".
43+
See https://github.com/ralphbean/bugwarrior/issues/733.
44+
"""
45+
self.taskwarrior.task_add('depends filter does not work with IDs')
46+
tasks = self.taskwarrior.load_tasks()
47+
assert len(tasks['pending']) == 1
48+
assert (tasks['pending'][0]['description']
49+
== 'depends filter does not work with IDs')

taskw/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def encode_task_experimental(task):
134134
task[k] = encode_task_value(k, task[k])
135135

136136
# Then, format it as a string
137-
return [
137+
return [task.pop('description')] + [
138138
"%s:\"%s\"" % (k, v) if v else "%s:" % (k, )
139139
for k, v in sorted(task.items(), key=itemgetter(0))
140140
]

0 commit comments

Comments
 (0)