Skip to content

Commit

Permalink
croniter: Add missing arguments and functions, add types (#6215)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Oct 30, 2021
1 parent 05cc30b commit 151f256
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
3 changes: 0 additions & 3 deletions stubs/croniter/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
croniter.CroniterError
croniter.croniter.__next__
croniter.croniter.expand
croniter.croniter.get_next
croniter.croniter.is_valid
croniter.croniter.next
38 changes: 33 additions & 5 deletions stubs/croniter/croniter.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
from typing import Any, Iterator, Text, Tuple, Type, TypeVar, Union
from typing_extensions import Literal

_RetType = Union[Type[float], Type[datetime.datetime]]
_SelfT = TypeVar("_SelfT", bound=croniter)
Expand All @@ -10,11 +11,25 @@ class CroniterBadDateError(CroniterError): ...
class CroniterNotAlphaError(CroniterError): ...

class croniter(Iterator[Any]):
MONTHS_IN_YEAR: int
MONTHS_IN_YEAR: Literal[12]
RANGES: Tuple[tuple[int, int], ...]
DAYS: Tuple[int, ...]
DAYS: tuple[
Literal[31],
Literal[28],
Literal[31],
Literal[30],
Literal[31],
Literal[30],
Literal[31],
Literal[31],
Literal[30],
Literal[31],
Literal[30],
Literal[31],
]
ALPHACONV: Tuple[dict[str, Any], ...]
LOWMAP: Tuple[dict[int, Any], ...]
LEN_MEANS_ALL: Tuple[int, ...]
bad_length: str
tzinfo: datetime.tzinfo | None
cur: float
Expand All @@ -34,9 +49,10 @@ class croniter(Iterator[Any]):
) -> None: ...
# Most return value depend on ret_type, which can be passed in both as a method argument and as
# a constructor argument.
def get_next(self, ret_type: _RetType | None = ...) -> Any: ...
def get_next(self, ret_type: _RetType | None = ..., start_time: float | datetime.datetime | None = ...) -> Any: ...
def get_prev(self, ret_type: _RetType | None = ...) -> Any: ...
def get_current(self, ret_type: _RetType | None = ...) -> Any: ...
def set_current(self, start_time: float | datetime.datetime) -> float: ...
def __iter__(self: _SelfT) -> _SelfT: ...
def __next__(self, ret_type: _RetType | None = ...) -> Any: ...
def next(self, ret_type: _RetType | None = ...) -> Any: ...
Expand All @@ -45,6 +61,18 @@ class croniter(Iterator[Any]):
def iter(self, ret_type: _RetType | None = ...) -> Iterator[Any]: ...
def is_leap(self, year: int) -> bool: ...
@classmethod
def expand(cls, expr_format: Text) -> tuple[list[list[str]], dict[str, Any]]: ...
def expand(cls, expr_format: Text, hash_id: str | bytes | None = ...) -> tuple[list[list[str]], dict[str, Any]]: ...
@classmethod
def is_valid(cls, expression: Text) -> bool: ...
def is_valid(cls, expression: Text, hash_id: str | bytes | None = ...) -> bool: ...
@classmethod
def match(cls, cron_expression: Text, testdate: float | datetime.datetime | None, day_or: bool = ...) -> bool: ...

def croniter_range(
start: float | datetime.datetime,
stop: float | datetime.datetime,
expr_format: Text,
ret_type: _RetType | None = ...,
day_or: bool = ...,
exclude_ends: bool = ...,
_croniter: Type[croniter] | None = ...,
) -> Iterator[Any]: ...

0 comments on commit 151f256

Please sign in to comment.