Skip to content

Commit a02118d

Browse files
authored
[python-crontab] Add default values (#16088)
1 parent 145ca22 commit a02118d

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

stubs/python-crontab/cronlog.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ class LogReader:
1313
size: int
1414
read: int
1515
pipe: StreamReaderWriter | None
16-
def __init__(self, filename: StrOrBytesPath, mass: int = ...) -> None: ...
16+
def __init__(self, filename: StrOrBytesPath, mass: int = 4096) -> None: ...
1717
def __enter__(self) -> Self: ...
1818
def __exit__(
1919
self, error_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
2020
) -> None: ...
2121
def __iter__(self) -> Iterator[str]: ...
22-
def readlines(self, until: int = ...) -> Generator[tuple[int, str]]: ...
22+
def readlines(self, until: int = 0) -> Generator[tuple[int, str]]: ...
2323

2424
def cron_date_to_datetime(cron_str: str) -> datetime: ...
2525

2626
class CronLog(LogReader):
2727
user: str | None
28-
def __init__(self, filename: StrOrBytesPath = ..., user: str | None = ...) -> None: ...
28+
def __init__(self, filename: StrOrBytesPath = "/var/log/syslog", user: str | None = None) -> None: ...
2929
def for_program(self, command: str) -> ProgramLog: ...
3030
def __iter__(self) -> dict[str, str | None]: ... # type: ignore[override]
3131

stubs/python-crontab/crontab.pyi

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CronTab:
7171
intab: str | None
7272
tabfile: str | None
7373
def __init__(
74-
self, user: _User = ..., tab: str | None = ..., tabfile: str | None = ..., log: CronLog | str | None = ...
74+
self, user: _User = None, tab: str | None = None, tabfile: str | None = None, log: CronLog | str | None = None
7575
) -> None: ...
7676
def __enter__(self) -> Self: ...
7777
def __exit__(
@@ -83,28 +83,28 @@ class CronTab:
8383
def user(self) -> _User: ...
8484
@property
8585
def user_opt(self) -> dict[str, str]: ...
86-
def read(self, filename: str | None = ...) -> None: ...
86+
def read(self, filename: str | None = None) -> None: ...
8787
def append(
8888
self,
8989
item: CronItem,
90-
line: str = ...,
91-
read: bool = ...,
92-
before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem] | None = ...,
90+
line: str = "",
91+
read: bool = False,
92+
before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem] | None = None,
9393
) -> None: ...
94-
def write(self, filename: str | None = ..., user: _User = ..., errors: bool = ...) -> None: ...
95-
def write_to_user(self, user: bool | str = ...) -> None: ...
94+
def write(self, filename: str | None = None, user: _User = None, errors: bool = False) -> None: ...
95+
def write_to_user(self, user: bool | str = True) -> None: ...
9696
# Usually `kwargs` are just `now: datetime | None`, but technically this can
9797
# work for `CronItem` subclasses, which might define other kwargs.
98-
def run_pending(self, *, now: datetime | None = ..., **kwargs: Any) -> Iterator[str]: ...
98+
def run_pending(self, *, now: datetime | None = None, **kwargs: Any) -> Iterator[str]: ...
9999
def run_scheduler(self, timeout: int = -1, cadence: int = 60, warp: bool = False) -> Iterator[str]: ...
100-
def render(self, errors: bool = ...) -> str: ...
100+
def render(self, errors: bool = False) -> str: ...
101101
def new(
102102
self,
103-
command: str = ...,
104-
comment: str = ...,
105-
user: str | None = ...,
106-
pre_comment: bool = ...,
107-
before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem] | None = ...,
103+
command: str = "",
104+
comment: str = "",
105+
user: str | None = None,
106+
pre_comment: bool = False,
107+
before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem] | None = None,
108108
) -> CronItem: ...
109109
def find_command(self, command: str | re.Pattern[str]) -> Iterator[CronItem]: ...
110110
def find_comment(self, comment: str | re.Pattern[str]) -> Iterator[CronItem]: ...
@@ -137,25 +137,25 @@ class CronItem:
137137
marker: str | None
138138
stdin: str | None
139139
slices: CronSlices
140-
def __init__(self, command: str = ..., comment: str = ..., user: _User = ..., pre_comment: bool = ...) -> None: ...
140+
def __init__(self, command: str = "", comment: str = "", user: _User = None, pre_comment: bool = False) -> None: ...
141141
def __hash__(self) -> int: ...
142142
def __eq__(self, other: object) -> bool: ...
143143
@classmethod
144-
def from_line(cls, line: str, user: str | None = ..., cron: CronTab | None = ...) -> Self: ...
144+
def from_line(cls, line: str, user: str | None = None, cron: CronTab | None = None) -> Self: ...
145145
def delete(self) -> None: ...
146-
def set_command(self, cmd: str, parse_stdin: bool = ...) -> None: ...
147-
def set_comment(self, cmt: str, pre_comment: bool = ...) -> None: ...
146+
def set_command(self, cmd: str, parse_stdin: bool = False) -> None: ...
147+
def set_comment(self, cmt: str, pre_comment: bool = False) -> None: ...
148148
def parse(self, line: str) -> None: ...
149-
def enable(self, enabled: bool = ...) -> bool: ...
149+
def enable(self, enabled: bool = True) -> bool: ...
150150
def is_enabled(self) -> bool: ...
151151
def is_valid(self) -> bool: ...
152152
def render(self) -> str: ...
153153
def every_reboot(self) -> None: ...
154-
def every(self, unit: int = ...) -> Every: ...
154+
def every(self, unit: int = 1) -> Every: ...
155155
def setall(self, *args: Any) -> None: ...
156156
def clear(self) -> None: ...
157-
def frequency(self, year: int | None = ...) -> int: ...
158-
def frequency_per_year(self, year: int | None = ...) -> int: ...
157+
def frequency(self, year: int | None = None) -> int: ...
158+
def frequency_per_year(self, year: int | None = None) -> int: ...
159159
def frequency_per_day(self) -> int: ...
160160
def frequency_per_hour(self) -> int: ...
161161
def frequency_at_year(self, year: int | None = None) -> int: ...
@@ -175,9 +175,9 @@ class CronItem:
175175
@overload
176176
def frequency_at_hour(self, year: None = None, month: None = None, day: None = None, hour: None = None) -> int: ...
177177

178-
def run_pending(self, now: datetime | None = ...) -> int | str: ...
178+
def run_pending(self, now: datetime | None = None) -> int | str: ...
179179
def run(self) -> str: ...
180-
def schedule(self, date_from: datetime | None = ...) -> croniter: ...
180+
def schedule(self, date_from: datetime | None = None) -> croniter: ...
181181
def description(
182182
self,
183183
*,
@@ -232,8 +232,8 @@ class CronSlices(list[CronSlice]):
232232
def clean_render(self) -> str: ...
233233
def render(self) -> str: ...
234234
def clear(self) -> None: ...
235-
def frequency(self, year: int | None = ...) -> int: ...
236-
def frequency_per_year(self, year: int | None = ...) -> int: ...
235+
def frequency(self, year: int | None = None) -> int: ...
236+
def frequency_per_year(self, year: int | None = None) -> int: ...
237237
def frequency_per_day(self) -> int: ...
238238
def frequency_per_hour(self) -> int: ...
239239
def frequency_at_year(self, year: int | None = None) -> int: ...
@@ -274,23 +274,23 @@ class CronSlice:
274274
name: str | None
275275
enum: list[str | None] | None
276276
parts: list[_Part]
277-
def __init__(self, info: int | dict[str, Any], value: str | None = ...) -> None: ...
277+
def __init__(self, info: int | dict[str, Any], value: str | None = None) -> None: ...
278278
def __hash__(self) -> int: ...
279279
def parse(self, value: str | None) -> None: ...
280280
def render(self, resolve: bool = False) -> str: ...
281281
def __eq__(self, arg: object) -> bool: ...
282-
def every(self, n_value: int, also: bool = ...) -> _Part: ...
282+
def every(self, n_value: int, also: bool = False) -> _Part: ...
283283
# The only known kwarg, others are unused,
284284
# `*args`` are passed to `parse_value`, so they are `Any`
285-
def on(self, *n_value: Any, also: bool = ...) -> list[_Part]: ...
286-
def during(self, vfrom: int | str, vto: int | str, also: bool = ...) -> _Part: ...
285+
def on(self, *n_value: Any, also: bool = False) -> list[_Part]: ...
286+
def during(self, vfrom: int | str, vto: int | str, also: bool = False) -> _Part: ...
287287
@property
288288
def also(self) -> Also: ...
289289
def clear(self) -> None: ...
290290
def get_range(self, *vrange: int | str | CronValue) -> list[int | CronRange]: ...
291291
def __iter__(self) -> Iterator[int]: ...
292292
def __len__(self) -> int: ...
293-
def parse_value(self, val: str, sunday: int | None = ...) -> int | CronValue: ...
293+
def parse_value(self, val: str, sunday: int | None = None) -> int | CronValue: ...
294294
def test_value(self, value: str, sunday: int | None = None) -> str: ...
295295

296296
def get_cronvalue(value: int, enums: list[str]) -> int | CronValue: ...
@@ -313,7 +313,7 @@ class CronRange:
313313
vto: int | CronValue
314314
def parse(self, value: str) -> None: ...
315315
def all(self) -> None: ...
316-
def render(self, resolve: bool = ...) -> str: ...
316+
def render(self, resolve: bool = False) -> str: ...
317317
def range(self) -> _range: ...
318318
def every(self, value: int | str) -> None: ...
319319
def __lt__(self, value: object) -> bool: ...

stubs/python-crontab/crontabs.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ from typing import Any
33
from crontab import CronTab
44

55
class UserSpool(list[CronTab]):
6-
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
6+
def __init__(self, loc: str, tabs: CronTabs | None = None) -> None: ...
77
def listdir(self, loc: str) -> list[str]: ...
88
def get_owner(self, path: str) -> str: ...
99
def generate(self, loc: str, username: str) -> CronTab: ...
1010

1111
class SystemTab(list[CronTab]):
12-
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
12+
def __init__(self, loc: str, tabs: CronTabs | None = None) -> None: ...
1313

1414
class AnaCronTab(list[CronTab]):
15-
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
15+
def __init__(self, loc: str, tabs: CronTabs | None = None) -> None: ...
1616
def add(self, loc: str, item: str, anajob: CronTab) -> CronTab: ...
1717

1818
KNOWN_LOCATIONS: list[tuple[UserSpool | SystemTab | AnaCronTab, str]]

0 commit comments

Comments
 (0)