Skip to content

Commit c2f87d5

Browse files
authored
refactor(core): delegate TaskRowDto.to_dict to model_dump(mode="json") (#1105)
The hand-written to_dict mapped all 20 fields one by one, duplicating exactly what Pydantic's model_dump(mode="json") already produces: enums to their .value, datetimes/date keys to ISO strings, primitives untouched. Verified byte-for-byte equal (keys and values) on a fully populated row, and the exporter/presenter suites (105 tests) that consume it still pass. Net -27 LOC, no behavior change.
1 parent 81cdaca commit c2f87d5

1 file changed

Lines changed: 1 addition & 28 deletions

File tree

  • packages/taskdog-core/src/taskdog_core/application/dto

packages/taskdog-core/src/taskdog_core/application/dto/task_dto.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,34 +127,7 @@ def to_dict(self) -> dict[str, object]:
127127
Returns:
128128
Dictionary with all task fields, using string values for enums and ISO format for datetimes.
129129
"""
130-
return {
131-
"id": self.id,
132-
"name": self.name,
133-
"priority": self.priority,
134-
"status": self.status.value,
135-
"planned_start": self.planned_start.isoformat()
136-
if self.planned_start
137-
else None,
138-
"planned_end": self.planned_end.isoformat() if self.planned_end else None,
139-
"deadline": self.deadline.isoformat() if self.deadline else None,
140-
"actual_start": self.actual_start.isoformat()
141-
if self.actual_start
142-
else None,
143-
"actual_end": self.actual_end.isoformat() if self.actual_end else None,
144-
"estimated_duration": self.estimated_duration,
145-
"actual_duration_hours": self.actual_duration_hours,
146-
"is_fixed": self.is_fixed,
147-
"depends_on": self.depends_on,
148-
"tags": self.tags,
149-
"daily_allocations": {
150-
k.isoformat(): v for k, v in self.daily_allocations.items()
151-
},
152-
"is_archived": self.is_archived,
153-
"is_finished": self.is_finished,
154-
"created_at": self.created_at.isoformat(),
155-
"updated_at": self.updated_at.isoformat(),
156-
"has_notes": self.has_notes,
157-
}
130+
return self.model_dump(mode="json")
158131

159132

160133
class TaskDetailDto(BaseModel):

0 commit comments

Comments
 (0)