Skip to content

Commit 5a9544f

Browse files
ellieayladonbarbosbrianschubert
authored
[python-dateutil] Make dateutil.parser.parse(fuzzy_with_tokens=True) return a tuple (#15474)
Co-authored-by: ellieayla <1447600+me@users.noreply.github.com> Co-authored-by: Semyon Moroz <donbarbos@proton.me> Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
1 parent 944838f commit 5a9544f

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

stubs/python-dateutil/dateutil/parser/_parser.pyi

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from _typeshed import SupportsRead
33
from collections.abc import Callable, Mapping
44
from datetime import _TzInfo, datetime
55
from io import StringIO
6-
from typing import IO, Any
6+
from typing import IO, Any, Literal, overload
77
from typing_extensions import Self, TypeAlias
88

99
_FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any]
@@ -77,6 +77,7 @@ class _ymd(list[int]):
7777
class parser:
7878
info: parserinfo
7979
def __init__(self, info: parserinfo | None = None) -> None: ...
80+
@overload
8081
def parse(
8182
self,
8283
timestr: _FileOrStr,
@@ -87,11 +88,25 @@ class parser:
8788
dayfirst: bool | None = ...,
8889
yearfirst: bool | None = ...,
8990
fuzzy: bool = ...,
90-
fuzzy_with_tokens: bool = ...,
91+
fuzzy_with_tokens: Literal[False] = False,
9192
) -> datetime: ...
93+
@overload
94+
def parse(
95+
self,
96+
timestr: _FileOrStr,
97+
default: datetime | None = None,
98+
ignoretz: bool = False,
99+
tzinfos: _TzInfos | None = None,
100+
*,
101+
dayfirst: bool | None = ...,
102+
yearfirst: bool | None = ...,
103+
fuzzy: bool = ...,
104+
fuzzy_with_tokens: Literal[True],
105+
) -> tuple[datetime, tuple[str, ...]]: ...
92106

93107
DEFAULTPARSER: parser
94108

109+
@overload
95110
def parse(
96111
timestr: _FileOrStr,
97112
parserinfo: parserinfo | None = None,
@@ -100,10 +115,23 @@ def parse(
100115
yearfirst: bool | None = ...,
101116
ignoretz: bool = ...,
102117
fuzzy: bool = ...,
103-
fuzzy_with_tokens: bool = ...,
118+
fuzzy_with_tokens: Literal[False] = False,
104119
default: datetime | None = ...,
105120
tzinfos: _TzInfos | None = ...,
106121
) -> datetime: ...
122+
@overload
123+
def parse(
124+
timestr: _FileOrStr,
125+
parserinfo: parserinfo | None = None,
126+
*,
127+
dayfirst: bool | None = ...,
128+
yearfirst: bool | None = ...,
129+
ignoretz: bool = ...,
130+
fuzzy: bool = ...,
131+
fuzzy_with_tokens: Literal[True],
132+
default: datetime | None = ...,
133+
tzinfos: _TzInfos | None = ...,
134+
) -> tuple[datetime, tuple[str, ...]]: ...
107135

108136
class _tzparser:
109137
class _result(_resultbase):

0 commit comments

Comments
 (0)