Skip to content

Commit b96eece

Browse files
authored
fix: Fix import errors introduced in CronTrigger feature (#1649)
Add croniter to requirements.txt, and change the import of the stub-only `datetime._TzInfo` to only run when type checking
1 parent a6ec7f3 commit b96eece

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

interactions/models/internal/tasks/triggers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import typing
12
from abc import ABC, abstractmethod
2-
from datetime import datetime, timedelta, timezone, _TzInfo
3+
from datetime import datetime, timedelta, timezone
4+
5+
if typing.TYPE_CHECKING:
6+
from datetime import _TzInfo
37

48
from croniter import croniter
59

@@ -154,7 +158,7 @@ class CronTrigger(BaseTrigger):
154158
155159
"""
156160

157-
def __init__(self, cron: str, tz: _TzInfo = timezone.utc) -> None:
161+
def __init__(self, cron: str, tz: "_TzInfo" = timezone.utc) -> None:
158162
self.cron = cron
159163
self.tz = tz
160164

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
aiohttp
22
attrs>=22.1
3+
croniter
34
discord-typings>=0.5.1
45
emoji
56
tomli

0 commit comments

Comments
 (0)