diff --git a/configuration.py b/configuration.py index 400bb5a..29dbcd3 100644 --- a/configuration.py +++ b/configuration.py @@ -23,7 +23,7 @@ class Config(object): return yconfig - def reload(self): + def reload(self) -> None: yconfig = self._load_config() logging.config.dictConfig(yconfig["logging"]) self.GROUPS = yconfig["groups"]["enable"] diff --git a/func_chengyu.py b/func_chengyu.py index 131d011..e50f228 100644 --- a/func_chengyu.py +++ b/func_chengyu.py @@ -23,10 +23,10 @@ class Chengyu(object): return cys, zis, yins - def isChengyu(self, cy): + def isChengyu(self, cy: str) -> bool: return self.cys.get(cy, None) is not None - def getNext(self, cy, tongyin=True) -> str: + def getNext(self, cy: str, tongyin: bool = True) -> str: """获取下一个成语 cy: 当前成语 tongyin: 是否允许同音字 @@ -56,7 +56,7 @@ class Chengyu(object): return None - def getMeaning(self, cy): + def getMeaning(self, cy: str) -> str: ress = self.df[self.df["chengyu"] == cy].to_dict(orient="records") if ress: res = ress[0] diff --git a/job_mgmt.py b/job_mgmt.py index 24a1499..6f7a0db 100644 --- a/job_mgmt.py +++ b/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() diff --git a/main.py b/main.py index fcbc203..7228552 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from wcferry import Wcf from robot import Robot -def weather_report(robot: Robot): +def weather_report(robot: Robot) -> None: """模拟发送天气预报 """ # 获取接收人