Skip to content

Commit 466f4f2

Browse files
authored
[croniter] Update to 6.2.0 (#15511)
1 parent 6e32e08 commit 466f4f2

File tree

4 files changed

+47
-35
lines changed

4 files changed

+47
-35
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
croniter.tests.*

stubs/croniter/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "6.0.0"
1+
version = "6.2.0"
22
upstream_repository = "https://github.com/pallets-eco/croniter"

stubs/croniter/croniter/__init__.pyi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ from .croniter import (
2020
)
2121

2222
cron_m = croniter_m
23+
24+
__all__ = [
25+
"DAY_FIELD",
26+
"HOUR_FIELD",
27+
"MINUTE_FIELD",
28+
"MONTH_FIELD",
29+
"OVERFLOW32B_MODE",
30+
"SECOND_FIELD",
31+
"UTC_DT",
32+
"YEAR_FIELD",
33+
"CroniterBadCronError",
34+
"CroniterBadDateError",
35+
"CroniterBadTypeRangeError",
36+
"CroniterError",
37+
"CroniterNotAlphaError",
38+
"CroniterUnsupportedSyntaxError",
39+
"cron_m",
40+
"croniter",
41+
"croniter_range",
42+
"datetime_to_timestamp",
43+
]

stubs/croniter/croniter/croniter.pyi

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import datetime
22
from _typeshed import Unused
3-
from collections import OrderedDict
4-
from collections.abc import Generator
3+
from collections.abc import Generator, Iterable
54
from re import Match, Pattern
65
from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only
76
from typing_extensions import Never, Self, TypeAlias
87

98
_R_co = TypeVar("_R_co", float, datetime.datetime, default=float, covariant=True)
109
_R2_co = TypeVar("_R2_co", float, datetime.datetime, covariant=True)
1110
_Expressions: TypeAlias = list[str] # fixed-length list of 5 or 6 strings
11+
ExpandedExpression: TypeAlias = list[int | Literal["*", "l"]]
1212

1313
@type_check_only
1414
class _AllIter(Protocol[_R_co]):
@@ -45,10 +45,12 @@ YEAR_FIELDS: Final[tuple[int, int, int, int, int, int, int]]
4545
step_search_re: Final[Pattern[str]]
4646
only_int_re: Final[Pattern[str]]
4747

48+
DAYS: Final[tuple[int, int, int, int, int, int, int, int, int, int, int, int]]
4849
WEEKDAYS: Final[str]
4950
MONTHS: Final[str]
5051
star_or_int_re: Final[Pattern[str]]
5152
special_dow_re: Final[Pattern[str]]
53+
nearest_weekday_re: Final[Pattern[str]]
5254
re_star: Final[Pattern[str]]
5355
hash_expression_re: Final[Pattern[str]]
5456

@@ -57,11 +59,8 @@ UNIX_CRON_LEN: Final = 5
5759
SECOND_CRON_LEN: Final = 6
5860
YEAR_CRON_LEN: Final = 7
5961
VALID_LEN_EXPRESSION: Final[set[int]]
60-
TIMESTAMP_TO_DT_CACHE: Final[dict[tuple[float, str], datetime.datetime]]
61-
EXPRESSIONS: dict[tuple[str, bytes], _Expressions]
6262
MARKER: object
6363

64-
def timedelta_to_seconds(td: datetime.timedelta) -> float: ...
6564
def datetime_to_timestamp(d: datetime.datetime) -> float: ...
6665

6766
class CroniterError(ValueError): ...
@@ -78,22 +77,6 @@ class croniter(Generic[_R_co]):
7877
tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]
7978
]
8079
]
81-
DAYS: Final[
82-
tuple[
83-
Literal[31],
84-
Literal[28],
85-
Literal[31],
86-
Literal[30],
87-
Literal[31],
88-
Literal[30],
89-
Literal[31],
90-
Literal[31],
91-
Literal[30],
92-
Literal[31],
93-
Literal[30],
94-
Literal[31],
95-
]
96-
]
9780
ALPHACONV: Final[
9881
tuple[
9982
dict[Never, Never],
@@ -121,15 +104,15 @@ class croniter(Generic[_R_co]):
121104
second_at_beginning: bool
122105
tzinfo: datetime.tzinfo | None
123106

124-
# Initialized to None, but immediately set to a float.
125107
start_time: float
126108
dst_start_time: float
127109
cur: float
128110

129111
expanded: list[list[str]]
130112
nth_weekday_of_month: dict[str, set[int]]
131-
fields: tuple[int, ...]
132113
expressions: _Expressions
114+
nearest_weekday: set[int]
115+
fields: tuple[int, ...]
133116

134117
@overload
135118
def __new__(
@@ -142,7 +125,7 @@ class croniter(Generic[_R_co]):
142125
is_prev: bool = False,
143126
hash_id: str | bytes | None = None,
144127
implement_cron_bug: bool = False,
145-
second_at_beginning: bool | None = None,
128+
second_at_beginning: bool = False,
146129
expand_from_start_time: bool = False,
147130
) -> croniter[float]: ...
148131
@overload
@@ -156,7 +139,7 @@ class croniter(Generic[_R_co]):
156139
is_prev: bool = False,
157140
hash_id: str | bytes | None = None,
158141
implement_cron_bug: bool = False,
159-
second_at_beginning: bool | None = None,
142+
second_at_beginning: bool = False,
160143
expand_from_start_time: bool = False,
161144
) -> croniter[datetime.datetime]: ...
162145
@overload
@@ -170,7 +153,7 @@ class croniter(Generic[_R_co]):
170153
is_prev: bool = False,
171154
hash_id: str | bytes | None = None,
172155
implement_cron_bug: bool = False,
173-
second_at_beginning: bool | None = None,
156+
second_at_beginning: bool = False,
174157
expand_from_start_time: bool = False,
175158
) -> croniter[datetime.datetime]: ...
176159
def __init__(
@@ -183,7 +166,7 @@ class croniter(Generic[_R_co]):
183166
is_prev: bool = False,
184167
hash_id: str | bytes | None = None,
185168
implement_cron_bug: bool = False,
186-
second_at_beginning: bool | None = None,
169+
second_at_beginning: bool = False,
187170
expand_from_start_time: bool = False,
188171
) -> None: ...
189172
@overload
@@ -210,8 +193,6 @@ class croniter(Generic[_R_co]):
210193
@staticmethod
211194
def datetime_to_timestamp(d: datetime.datetime) -> float: ...
212195
def timestamp_to_datetime(self, timestamp: float, tzinfo: datetime.tzinfo | None = ...) -> datetime.datetime: ...
213-
@staticmethod
214-
def timedelta_to_seconds(td: datetime.timedelta) -> float: ...
215196
@overload
216197
def all_next(
217198
self, ret_type: type[_R2_co], start_time: float | datetime.datetime | None = None, update_current: bool | None = None
@@ -247,26 +228,33 @@ class croniter(Generic[_R_co]):
247228
update_current: bool | None = None,
248229
) -> _R_co: ...
249230
__next__ = next
250-
@staticmethod
251-
def is_leap(year: int) -> bool: ...
252231
@classmethod
253232
def value_alias(
254233
cls,
255234
val: int,
256235
field_index: Literal[0, 1, 2, 3, 4, 5, 6],
257236
len_expressions: int | list[Any] | dict[Any, Any] | tuple[Any, ...] | set[Any] = 5,
258237
) -> int: ...
238+
DAYS_IN_MONTH: Final[dict[int, int]]
259239
@classmethod
260240
def expand(
261241
cls,
262242
expr_format: str,
263243
hash_id: bytes | None = None,
264244
second_at_beginning: bool = False,
265245
from_timestamp: float | None = None,
266-
) -> tuple[list[list[str]], dict[str, set[int]]]: ...
246+
strict: bool = False,
247+
strict_year: int | Iterable[int] | None = None,
248+
) -> tuple[list[ExpandedExpression], dict[str, set[int]]]: ...
267249
@classmethod
268250
def is_valid(
269-
cls, expression: str, hash_id: bytes | None = None, encoding: str = "UTF-8", second_at_beginning: bool = False
251+
cls,
252+
expression: str,
253+
hash_id: bytes | None = None,
254+
encoding: str = "UTF-8",
255+
second_at_beginning: bool = False,
256+
strict: bool = False,
257+
strict_year: int | Iterable[int] | None = None,
270258
) -> bool: ...
271259
@classmethod
272260
def match(
@@ -275,6 +263,7 @@ class croniter(Generic[_R_co]):
275263
testdate: float | datetime.datetime | None,
276264
day_or: bool = True,
277265
second_at_beginning: bool = False,
266+
precision_in_seconds: int | None = None,
278267
) -> bool: ...
279268
@classmethod
280269
def match_range(
@@ -284,6 +273,7 @@ class croniter(Generic[_R_co]):
284273
to_datetime: datetime.datetime,
285274
day_or: bool = True,
286275
second_at_beginning: bool = False,
276+
precision_in_seconds: int | None = None,
287277
) -> bool: ...
288278

289279
@overload
@@ -354,4 +344,4 @@ class HashExpander:
354344
**kw: object,
355345
) -> str: ...
356346

357-
EXPANDERS: OrderedDict[str, HashExpander]
347+
EXPANDERS: dict[str, type[HashExpander]]

0 commit comments

Comments
 (0)