Skip to content

Commit d6e5369

Browse files
authored
python-dateutil: add overload to rrulestr (#14815)
1 parent a02656a commit d6e5369

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Union
2+
from typing_extensions import assert_type
3+
4+
from dateutil.rrule import rrule, rruleset, rrulestr
5+
6+
rs1 = rrulestr("", forceset=True)
7+
assert_type(rs1, rruleset)
8+
9+
rs2 = rrulestr("", compatible=True)
10+
assert_type(rs2, rruleset)
11+
12+
rs3 = rrulestr("")
13+
assert_type(rs3, Union[rrule, rruleset])

stubs/python-dateutil/dateutil/rrule.pyi

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
from _typeshed import Incomplete
33
from collections.abc import Generator, Iterable, Iterator, Sequence
4-
from typing import Final, Literal
4+
from typing import Final, Literal, overload
55
from typing_extensions import Self, TypeAlias
66

77
from ._common import weekday as weekdaybase
@@ -174,6 +174,35 @@ class rruleset(rrulebase):
174174
def exdate(self, exdate) -> None: ...
175175

176176
class _rrulestr:
177+
@overload
178+
def __call__(
179+
self,
180+
s: str,
181+
*,
182+
forceset: Literal[True],
183+
dtstart: datetime.date | None = None,
184+
cache: bool | None = None,
185+
unfold: bool = False,
186+
compatible: bool = False,
187+
ignoretz: bool = False,
188+
tzids=None,
189+
tzinfos=None,
190+
) -> rruleset: ...
191+
@overload
192+
def __call__(
193+
self,
194+
s: str,
195+
*,
196+
compatible: Literal[True],
197+
dtstart: datetime.date | None = None,
198+
cache: bool | None = None,
199+
unfold: bool = False,
200+
forceset: bool = False,
201+
ignoretz: bool = False,
202+
tzids=None,
203+
tzinfos=None,
204+
) -> rruleset: ...
205+
@overload
177206
def __call__(
178207
self,
179208
s: str,

0 commit comments

Comments
 (0)