Skip to content

Commit 376ade3

Browse files
committed
Add type hints to dicts
Add type hints to dicts to make mypy happy.
1 parent c587622 commit 376ade3

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/croniter/croniter.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sys
1212
import traceback as _traceback
1313
from time import time
14+
from typing import Optional, Union
1415

1516
from dateutil.relativedelta import relativedelta
1617
from dateutil.tz import tzutc
@@ -59,12 +60,12 @@ def is_32bit():
5960
EPOCH = datetime.datetime.fromtimestamp(0, UTC_DT)
6061

6162
# fmt: off
62-
M_ALPHAS = {
63+
M_ALPHAS: dict[str, Union[int, str]] = {
6364
"jan": 1, "feb": 2, "mar": 3, "apr": 4, # noqa: E241
6465
"may": 5, "jun": 6, "jul": 7, "aug": 8, # noqa: E241
6566
"sep": 9, "oct": 10, "nov": 11, "dec": 12,
6667
}
67-
DOW_ALPHAS = {
68+
DOW_ALPHAS: dict[str, Union[int, str]] = {
6869
"sun": 0, "mon": 1, "tue": 2, "wed": 3, "thu": 4, "fri": 5, "sat": 6
6970
}
7071

@@ -109,8 +110,8 @@ def is_32bit():
109110
YEAR_CRON_LEN = len(YEAR_FIELDS)
110111
# retrocompat
111112
VALID_LEN_EXPRESSION = {a for a in CRON_FIELDS if isinstance(a, int)}
112-
TIMESTAMP_TO_DT_CACHE = {}
113-
EXPRESSIONS = {}
113+
TIMESTAMP_TO_DT_CACHE: dict[int, datetime.datetime] = {}
114+
EXPRESSIONS: dict[tuple[str, Optional[bytes], bool], list[str]] = {}
114115
MARKER = object()
115116

116117

@@ -176,7 +177,7 @@ class croniter:
176177
(1970, 2099),
177178
)
178179

179-
ALPHACONV = (
180+
ALPHACONV: tuple[dict[str, Union[int, str]], ...] = (
180181
{}, # 0: min
181182
{}, # 1: hour
182183
{"l": "l"}, # 2: dom
@@ -190,7 +191,7 @@ class croniter:
190191
{},
191192
)
192193

193-
LOWMAP = (
194+
LOWMAP: tuple[dict[int, int], ...] = (
194195
{},
195196
{},
196197
{0: 1},

src/croniter/tests/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class TestCase(unittest.TestCase):
77
If necessary, we can put common utility or setup code in here.
88
"""
99

10-
maxDiff = 10**10
10+
maxDiff: int | None = 10**10

0 commit comments

Comments
 (0)