[python-dateutil] Complete stubs (#15476)

This commit is contained in:
Semyon Moroz
2026-03-05 01:43:10 +00:00
committed by GitHub
parent b0401bc7df
commit e108320b29
7 changed files with 14 additions and 11 deletions
@@ -153,7 +153,7 @@ class _tzparser:
day: int | None
time: int | None
def __init__(self): ...
def __init__(self) -> None: ...
def parse(self, tzstr: str | re.Pattern[str]) -> _result | None: ...
@@ -8,7 +8,7 @@ _TakesAscii: TypeAlias = str | bytes | _Readable
__all__ = ["isoparse", "isoparser"]
class isoparser:
def __init__(self, sep: str | bytes | None = None): ...
def __init__(self, sep: str | bytes | None = None) -> None: ...
def isoparse(self, dt_str: _TakesAscii) -> datetime: ...
def parse_isodate(self, datestr: _TakesAscii) -> date: ...
def parse_isotime(self, timestr: _TakesAscii) -> time: ...
+2 -2
View File
@@ -62,8 +62,8 @@ class rrulebase:
def __getitem__(self, item: int | slice) -> datetime.datetime: ...
def __contains__(self, item: datetime.datetime) -> bool: ...
def count(self) -> int | None: ...
def before(self, dt: datetime.datetime, inc: bool = False): ...
def after(self, dt: datetime.datetime, inc: bool = False): ...
def before(self, dt: datetime.datetime, inc: bool = False) -> datetime.datetime | None: ...
def after(self, dt: datetime.datetime, inc: bool = False) -> datetime.datetime | None: ...
def xafter(self, dt: datetime.datetime, count: int | None = None, inc: bool = False) -> Generator[datetime.datetime]: ...
def between(
self, after: datetime.datetime, before: datetime.datetime, inc: bool = False, count: int = 1
@@ -10,9 +10,10 @@ __all__ = ["tzname_in_python2", "enfold"]
_P = ParamSpec("_P")
_R = TypeVar("_R")
_DateTimeT = TypeVar("_DateTimeT", bound=datetime)
def tzname_in_python2(namefunc: Callable[_P, _R]) -> Callable[_P, _R]: ...
def enfold(dt: datetime, fold: int = 1): ...
def enfold(dt: _DateTimeT, fold: int = 1) -> _DateTimeT: ...
# Doesn't actually have ABCMeta as the metaclass at runtime,
# but mypy complains if we don't have it in the stub.
+4 -4
View File
@@ -13,7 +13,7 @@ else:
tzwin: None
tzwinlocal: None
_DT = TypeVar("_DT", bound=datetime)
_DateTimeT = TypeVar("_DateTimeT", bound=datetime)
ZERO: timedelta
EPOCH: datetime
@@ -24,7 +24,7 @@ class tzutc(tzinfo):
def dst(self, dt: datetime | None) -> timedelta | None: ...
def tzname(self, dt: datetime | None) -> str: ...
def is_ambiguous(self, dt: datetime | None) -> bool: ...
def fromutc(self, dt: _DT) -> _DT: ...
def fromutc(self, dt: _DateTimeT) -> _DateTimeT: ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other: object) -> bool: ...
@@ -38,7 +38,7 @@ class tzoffset(tzinfo):
def dst(self, dt: datetime | None) -> timedelta | None: ...
def is_ambiguous(self, dt: datetime | None) -> bool: ...
def tzname(self, dt: datetime | None) -> str: ...
def fromutc(self, dt: _DT) -> _DT: ...
def fromutc(self, dt: _DateTimeT) -> _DateTimeT: ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other: object) -> bool: ...
@@ -126,7 +126,7 @@ TZPATHS: list[str]
def datetime_exists(dt: datetime, tz: tzinfo | None = None) -> bool: ...
def datetime_ambiguous(dt: datetime, tz: tzinfo | None = None) -> bool: ...
def resolve_imaginary(dt: datetime) -> datetime: ...
def resolve_imaginary(dt: _DateTimeT) -> _DateTimeT: ...
# Singleton type defined locally in a function. Calls itself "GettzFunc".
@type_check_only
+4 -1
View File
@@ -1,5 +1,8 @@
from datetime import _TzInfo, datetime, timedelta
from typing import TypeVar
_DateTimeT = TypeVar("_DateTimeT", bound=datetime)
def today(tzinfo: _TzInfo | None = None) -> datetime: ...
def default_tzinfo(dt: datetime, tzinfo: _TzInfo) -> datetime: ...
def default_tzinfo(dt: _DateTimeT, tzinfo: _TzInfo) -> _DateTimeT: ...
def within_delta(dt1: datetime, dt2: datetime, delta: timedelta) -> bool: ...