Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use field read_only attribute to determine which fields should be included in task_update call. #156

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

coddingtonbear
Copy link
Collaborator

We've historically had a list of fields we'd carefully remember to pop off of our task object before performing an update operation. We've also historically had a list of fields including whether those fields are read_only or not for use during serialization/deserialization of data. Let's just use that metadata for determining which fields are mutable and which aren't when performing a task_update operation.

EdwardBetts and others added 4 commits December 21, 2020 22:47
When modifying a task in taskwarrior 2.5.2 it was returning this error:

  The 'urgency' attribute does not allow a value of '0'.

The solution is to drop the urgency argument if the value is 0 when
calling task modify.

# Also, experimental mode returns the id. So, avoid comparing.
del tasks['pending'][0]['id']
calculated_fields = ['urgency', 'id', 'modified']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated whether to use field metadata here, too, and eventually landed on not using it so the test doesn't need to be aware of where field metadata is stored.

@@ -768,17 +768,15 @@ def task_update(self, task):
else:
task_uuid = task['uuid']

id, original_task = self.get_task(uuid=task_uuid)

if 'id' in task:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually a subtle bug -- we were mutating the passed-in task object instead of its copy (which we'll generate a few lines below).

@@ -204,11 +204,12 @@ def set(self, key, value):
""" Set a key's value regardless of whether a change is seen."""
return self.__setitem__(key, value, force=True)

def serialized(self):
def serialized(self, include_immutable=True):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't technically directly related to these changes, but shows a slight difference in approach in my first implementation of this. It's useful, though, in general for a side project and is backward-compatible, so I hope you'll forgive me for leaving this in.

@coddingtonbear
Copy link
Collaborator Author

Note that this build will fail until we merge #157. In the unlikely event that we can't agree to merge that PR, I'll update this one to not use the particular 3.6+ feature I'm using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants