Skip to content

Commit

Permalink
format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansub committed Feb 5, 2025
1 parent 350f3b7 commit 336f2bb
Showing 1 changed file with 81 additions and 80 deletions.
161 changes: 81 additions & 80 deletions libs/agno/agno/tools/todoist.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ def __init__(
if get_projects:
self.register(self.get_projects)

def create_task(self, content: str, project_id: Optional[str] = None,
due_string: Optional[str] = None, priority: Optional[int] = None,
labels: Optional[List[str]] = None) -> str:
def create_task(
self,
content: str,
project_id: Optional[str] = None,
due_string: Optional[str] = None,
priority: Optional[int] = None,
labels: Optional[List[str]] = None,
) -> str:
"""
Create a new task in Todoist.
Expand All @@ -79,34 +84,30 @@ def create_task(self, content: str, project_id: Optional[str] = None,
"""
try:
task = self.api.add_task(
content=content,
project_id=project_id,
due_string=due_string,
priority=priority,
labels=labels or []
content=content, project_id=project_id, due_string=due_string, priority=priority, labels=labels or []
)
# Convert task to a dictionary and handle the Due object
task_dict = {
'id': task.id,
'content': task.content,
'description': task.description,
'project_id': task.project_id,
'section_id': task.section_id,
'parent_id': task.parent_id,
'order': task.order,
'priority': task.priority,
'url': task.url,
'comment_count': task.comment_count,
'creator_id': task.creator_id,
'created_at': task.created_at,
'labels': task.labels,
"id": task.id,
"content": task.content,
"description": task.description,
"project_id": task.project_id,
"section_id": task.section_id,
"parent_id": task.parent_id,
"order": task.order,
"priority": task.priority,
"url": task.url,
"comment_count": task.comment_count,
"creator_id": task.creator_id,
"created_at": task.created_at,
"labels": task.labels,
}
if task.due:
task_dict['due'] = {
'date': task.due.date,
'string': task.due.string,
'datetime': task.due.datetime,
'timezone': task.due.timezone,
task_dict["due"] = {
"date": task.due.date,
"string": task.due.string,
"datetime": task.due.datetime,
"timezone": task.due.timezone,
}
return json.dumps(task_dict)
except Exception as e:
Expand All @@ -118,26 +119,26 @@ def get_task(self, task_id: str) -> str:
try:
task = self.api.get_task(task_id)
task_dict = {
'id': task.id,
'content': task.content,
'description': task.description,
'project_id': task.project_id,
'section_id': task.section_id,
'parent_id': task.parent_id,
'order': task.order,
'priority': task.priority,
'url': task.url,
'comment_count': task.comment_count,
'creator_id': task.creator_id,
'created_at': task.created_at,
'labels': task.labels,
"id": task.id,
"content": task.content,
"description": task.description,
"project_id": task.project_id,
"section_id": task.section_id,
"parent_id": task.parent_id,
"order": task.order,
"priority": task.priority,
"url": task.url,
"comment_count": task.comment_count,
"creator_id": task.creator_id,
"created_at": task.created_at,
"labels": task.labels,
}
if task.due:
task_dict['due'] = {
'date': task.due.date,
'string': task.due.string,
'datetime': task.due.datetime,
'timezone': task.due.timezone,
task_dict["due"] = {
"date": task.due.date,
"string": task.due.string,
"datetime": task.due.datetime,
"timezone": task.due.timezone,
}
return json.dumps(task_dict)
except Exception as e:
Expand All @@ -158,26 +159,26 @@ def update_task(self, task_id: str, **kwargs) -> str:
try:
task = self.api.update_task(task_id=task_id, **kwargs)
task_dict = {
'id': task.id,
'content': task.content,
'description': task.description,
'project_id': task.project_id,
'section_id': task.section_id,
'parent_id': task.parent_id,
'order': task.order,
'priority': task.priority,
'url': task.url,
'comment_count': task.comment_count,
'creator_id': task.creator_id,
'created_at': task.created_at,
'labels': task.labels,
"id": task.id,
"content": task.content,
"description": task.description,
"project_id": task.project_id,
"section_id": task.section_id,
"parent_id": task.parent_id,
"order": task.order,
"priority": task.priority,
"url": task.url,
"comment_count": task.comment_count,
"creator_id": task.creator_id,
"created_at": task.created_at,
"labels": task.labels,
}
if task.due:
task_dict['due'] = {
'date': task.due.date,
'string': task.due.string,
'datetime': task.due.datetime,
'timezone': task.due.timezone,
task_dict["due"] = {
"date": task.due.date,
"string": task.due.string,
"datetime": task.due.datetime,
"timezone": task.due.timezone,
}
return json.dumps(task_dict)
except Exception as e:
Expand Down Expand Up @@ -209,26 +210,26 @@ def get_active_tasks(self) -> str:
tasks_list = []
for task in tasks:
task_dict = {
'id': task.id,
'content': task.content,
'description': task.description,
'project_id': task.project_id,
'section_id': task.section_id,
'parent_id': task.parent_id,
'order': task.order,
'priority': task.priority,
'url': task.url,
'comment_count': task.comment_count,
'creator_id': task.creator_id,
'created_at': task.created_at,
'labels': task.labels,
"id": task.id,
"content": task.content,
"description": task.description,
"project_id": task.project_id,
"section_id": task.section_id,
"parent_id": task.parent_id,
"order": task.order,
"priority": task.priority,
"url": task.url,
"comment_count": task.comment_count,
"creator_id": task.creator_id,
"created_at": task.created_at,
"labels": task.labels,
}
if task.due:
task_dict['due'] = {
'date': task.due.date,
'string': task.due.string,
'datetime': task.due.datetime,
'timezone': task.due.timezone,
task_dict["due"] = {
"date": task.due.date,
"string": task.due.string,
"datetime": task.due.datetime,
"timezone": task.due.timezone,
}
tasks_list.append(task_dict)
return json.dumps(tasks_list)
Expand Down

0 comments on commit 336f2bb

Please sign in to comment.