Skip to content

Commit 5ca86c6

Browse files
committed
Scheduled task is a pydantic model now.
Signed-off-by: Pavel Kirilin <[email protected]>
1 parent dab1de4 commit 5ca86c6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/examples/extending/schedule_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Coroutine, List
1+
from typing import List
22

33
from taskiq import ScheduledTask, ScheduleSource
44

taskiq/scheduler/scheduled_task.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import uuid
2-
from dataclasses import dataclass, field
2+
from dataclasses import field
33
from datetime import datetime, timedelta
44
from typing import Any, Dict, List, Optional, Union
55

6+
from pydantic import BaseModel
67

7-
@dataclass
8-
class CronSpec:
8+
9+
class CronSpec(BaseModel):
910
"""Cron specification for running tasks."""
1011

1112
minutes: Optional[Union[str, int]] = "*"
@@ -21,8 +22,7 @@ def to_cron(self) -> str:
2122
return f"{self.minutes} {self.hours} {self.days} {self.months} {self.weekdays}"
2223

2324

24-
@dataclass(frozen=True, eq=True)
25-
class ScheduledTask:
25+
class ScheduledTask(BaseModel):
2626
"""Abstraction over task schedule."""
2727

2828
task_name: str

0 commit comments

Comments
 (0)