Add type hints
This commit is contained in:
13
job_mgmt.py
13
job_mgmt.py
@@ -2,13 +2,14 @@
|
||||
|
||||
import time
|
||||
import schedule
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
class Job(object):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def onEverySeconds(self, seconds, task, *args, **kwargs):
|
||||
def onEverySeconds(self, seconds: int, task: Callable[..., Any], *args, **kwargs) -> None:
|
||||
"""
|
||||
每 seconds 秒执行
|
||||
:param seconds: 间隔,秒
|
||||
@@ -17,7 +18,7 @@ class Job(object):
|
||||
"""
|
||||
schedule.every(seconds).seconds.do(task, *args, **kwargs)
|
||||
|
||||
def onEveryMinutes(self, minutes, task, *args, **kwargs):
|
||||
def onEveryMinutes(self, minutes: int, task: Callable[..., Any], *args, **kwargs) -> None:
|
||||
"""
|
||||
每 minutes 分钟执行
|
||||
:param minutes: 间隔,分钟
|
||||
@@ -26,7 +27,7 @@ class Job(object):
|
||||
"""
|
||||
schedule.every(minutes).minutes.do(task, *args, **kwargs)
|
||||
|
||||
def onEveryHours(self, hours, task, *args, **kwargs):
|
||||
def onEveryHours(self, hours: int, task: Callable[..., Any], *args, **kwargs) -> None:
|
||||
"""
|
||||
每 hours 小时执行
|
||||
:param hours: 间隔,小时
|
||||
@@ -35,7 +36,7 @@ class Job(object):
|
||||
"""
|
||||
schedule.every(hours).hours.do(task, *args, **kwargs)
|
||||
|
||||
def onEveryDays(self, days, task, *args, **kwargs):
|
||||
def onEveryDays(self, days: int, task: Callable[..., Any], *args, **kwargs) -> None:
|
||||
"""
|
||||
每 days 天执行
|
||||
:param days: 间隔,天
|
||||
@@ -44,7 +45,7 @@ class Job(object):
|
||||
"""
|
||||
schedule.every(days).days.do(task, *args, **kwargs)
|
||||
|
||||
def onEveryTime(self, times, task, *args, **kwargs):
|
||||
def onEveryTime(self, times: int, task: Callable[..., Any], *args, **kwargs) -> None:
|
||||
"""
|
||||
每天定时执行
|
||||
:param times: 时间字符串列表,格式:
|
||||
@@ -62,7 +63,7 @@ class Job(object):
|
||||
for t in times:
|
||||
schedule.every(1).days.at(t).do(task, *args, **kwargs)
|
||||
|
||||
def runPendingJobs(self):
|
||||
def runPendingJobs(self) -> None:
|
||||
schedule.run_pending()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user