[python-dateutil] add some missing parameter types (#14992)

This commit is contained in:
lev-blit
2025-11-07 23:00:29 +02:00
committed by GitHub
parent f7ff48e6cb
commit e524443825
5 changed files with 58 additions and 53 deletions
@@ -1,5 +1,5 @@
import re
from _typeshed import Incomplete, SupportsRead
from _typeshed import SupportsRead
from collections.abc import Callable, Mapping
from datetime import _TzInfo, datetime
from io import StringIO
@@ -58,22 +58,21 @@ class parserinfo:
def convertyear(self, year: int, century_specified: bool = False) -> int: ...
def validate(self, res: datetime) -> bool: ...
class _ymd(list[Incomplete]):
class _ymd(list[int]):
century_specified: bool
dstridx: int | None
mstridx: int | None
ystridx: int | None
def __init__(self, *args, **kwargs) -> None: ...
@property
def has_year(self) -> bool: ...
@property
def has_month(self) -> bool: ...
@property
def has_day(self) -> bool: ...
def could_be_day(self, value): ...
def append(self, val, label=None): ...
def _resolve_from_stridxs(self, strids): ...
def resolve_ymd(self, yearfirst: bool | None, dayfirst: bool | None): ...
def could_be_day(self, value: int) -> bool: ...
def append(self, val: str | int, label: str | None = None) -> None: ...
def _resolve_from_stridxs(self, strids: dict[str, int]) -> tuple[int, int, int]: ...
def resolve_ymd(self, yearfirst: bool | None, dayfirst: bool | None) -> tuple[int, int, int]: ...
class parser:
info: parserinfo
+28 -25
View File
@@ -1,9 +1,10 @@
import datetime
from _typeshed import Incomplete
from collections.abc import Generator, Iterable, Iterator, Sequence
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
from typing import Final, Literal, overload
from typing_extensions import Self, TypeAlias
from dateutil.parser._parser import _TzInfos
from ._common import weekday as weekdaybase
__all__ = [
@@ -58,13 +59,15 @@ SU: weekday
class rrulebase:
def __init__(self, cache: bool | None = False) -> None: ...
def __iter__(self) -> Iterator[datetime.datetime]: ...
def __getitem__(self, item): ...
def __contains__(self, item) -> bool: ...
def __getitem__(self, item: int | slice) -> datetime.datetime: ...
def __contains__(self, item: datetime.datetime) -> bool: ...
def count(self) -> int | None: ...
def before(self, dt, inc: bool = False): ...
def after(self, dt, inc: bool = False): ...
def xafter(self, dt, count=None, inc: bool = False) -> Generator[Incomplete]: ...
def between(self, after, before, inc: bool = False, count: int = 1) -> list[Incomplete]: ...
def before(self, dt: datetime.datetime, inc: bool = False): ...
def after(self, dt: datetime.datetime, inc: bool = False): ...
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
) -> list[datetime.datetime]: ...
class rrule(rrulebase):
def __init__(
@@ -156,22 +159,22 @@ class _iterinfo:
class rruleset(rrulebase):
class _genitem:
dt: Incomplete
genlist: list[Incomplete]
gen: Incomplete
def __init__(self, genlist, gen) -> None: ...
dt: datetime.datetime
genlist: list[Self]
gen: Iterator[datetime.datetime]
def __init__(self, genlist: list[Self], gen: Iterator[datetime.datetime]) -> None: ...
def __next__(self) -> None: ...
next = __next__
def __lt__(self, other) -> bool: ...
def __gt__(self, other) -> bool: ...
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
def __lt__(self, other: Self) -> bool: ...
def __gt__(self, other: Self) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __init__(self, cache: bool | None = False) -> None: ...
def rrule(self, rrule: _RRule) -> None: ...
def rdate(self, rdate) -> None: ...
def exrule(self, exrule) -> None: ...
def exdate(self, exdate) -> None: ...
def rdate(self, rdate: datetime.datetime) -> None: ...
def exrule(self, exrule: _RRule) -> None: ...
def exdate(self, exdate: datetime.datetime) -> None: ...
class _rrulestr:
@overload
@@ -185,8 +188,8 @@ class _rrulestr:
unfold: bool = False,
compatible: bool = False,
ignoretz: bool = False,
tzids=None,
tzinfos=None,
tzids: Callable[[str], datetime.tzinfo] | Mapping[str, datetime.tzinfo] | None = None,
tzinfos: _TzInfos | None = None,
) -> rruleset: ...
@overload
def __call__(
@@ -199,8 +202,8 @@ class _rrulestr:
unfold: bool = False,
forceset: bool = False,
ignoretz: bool = False,
tzids=None,
tzinfos=None,
tzids: Callable[[str], datetime.tzinfo] | Mapping[str, datetime.tzinfo] | None = None,
tzinfos: _TzInfos | None = None,
) -> rruleset: ...
@overload
def __call__(
@@ -213,8 +216,8 @@ class _rrulestr:
forceset: bool = False,
compatible: bool = False,
ignoretz: bool = False,
tzids=None,
tzinfos=None,
tzids: Callable[[str], datetime.tzinfo] | Mapping[str, datetime.tzinfo] | None = None,
tzinfos: _TzInfos | None = None,
) -> rrule | rruleset: ...
rrulestr: _rrulestr
@@ -24,5 +24,5 @@ class tzrangebase(_tzinfo):
def fromutc(self, dt: datetime) -> datetime: ...
def is_ambiguous(self, dt: datetime) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
def __ne__(self, other: object) -> bool: ...
__reduce__ = object.__reduce__
+21 -19
View File
@@ -1,6 +1,8 @@
import sys
from _typeshed import Unused
from datetime import datetime, timedelta, tzinfo
from typing import ClassVar, Literal, Protocol, TypeVar, type_check_only
from typing import Any, ClassVar, Literal, Protocol, TypeVar, type_check_only
from typing_extensions import Self
from ..relativedelta import relativedelta
from ._common import _tzinfo, enfold as enfold, tzrangebase
@@ -23,26 +25,26 @@ class tzutc(tzinfo):
def tzname(self, dt: datetime | None) -> str: ...
def is_ambiguous(self, dt: datetime | None) -> bool: ...
def fromutc(self, dt: _DT) -> _DT: ...
def __eq__(self, other): ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
def __ne__(self, other: object) -> bool: ...
__reduce__ = object.__reduce__
UTC: tzutc
class tzoffset(tzinfo):
def __init__(self, name, offset) -> None: ...
def __init__(self, name: str | None, offset: float | timedelta) -> None: ...
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
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 __eq__(self, other): ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
def __ne__(self, other: object) -> bool: ...
__reduce__ = object.__reduce__
@classmethod
def instance(cls, name, offset) -> tzoffset: ...
def instance(cls, name: str | None, offset: float | timedelta) -> tzoffset: ...
class tzlocal(_tzinfo):
def __init__(self) -> None: ...
@@ -50,9 +52,9 @@ class tzlocal(_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 __eq__(self, other): ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
def __ne__(self, other: object) -> bool: ...
__reduce__ = object.__reduce__
class _ttinfo:
@@ -65,9 +67,9 @@ class _ttinfo:
isgmt: bool
dstoffset: timedelta
def __init__(self) -> None: ...
def __eq__(self, other): ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
def __ne__(self, other: object) -> bool: ...
@type_check_only
class _TZFileReader(Protocol):
@@ -82,11 +84,11 @@ class tzfile(_tzinfo):
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
def dst(self, dt: datetime | None) -> timedelta | None: ...
def tzname(self, dt: datetime | None) -> str: ...
def __eq__(self, other): ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
def __reduce__(self): ...
def __reduce_ex__(self, protocol): ...
def __ne__(self, other: object) -> bool: ...
def __reduce__(self) -> tuple[type[Self], tuple[None, str], dict[str, Any]]: ...
def __reduce_ex__(self, protocol: Unused) -> tuple[type[Self], tuple[None, str], dict[str, Any]]: ...
class tzrange(tzrangebase):
hasdst: bool
@@ -100,13 +102,13 @@ class tzrange(tzrangebase):
end: relativedelta | None = None,
) -> None: ...
def transitions(self, year: int) -> tuple[datetime, datetime]: ...
def __eq__(self, other): ...
def __eq__(self, other: object) -> bool: ...
class tzstr(tzrange):
hasdst: bool
def __init__(self, s: str, posix_offset: bool = False) -> None: ...
@classmethod
def instance(cls, name, offset) -> tzoffset: ...
def instance(cls, name: str | None, offset: float | timedelta) -> tzoffset: ...
@type_check_only
class _ICalReader(Protocol):
@@ -116,8 +118,8 @@ class _ICalReader(Protocol):
class tzical:
def __init__(self, fileobj: str | _ICalReader) -> None: ...
def keys(self): ...
def get(self, tzid=None): ...
def keys(self) -> list[str]: ...
def get(self, tzid: str | None = None) -> tzinfo | None: ...
TZFILES: list[str]
TZPATHS: list[str]
@@ -16,7 +16,8 @@ ZONEFILENAME: Final[str]
METADATA_FN: Final[str]
class tzfile(_tzfile):
def __reduce__(self) -> tuple[Callable[[str], Self], tuple[str, ...]]: ...
# source code does this override, changing the type
def __reduce__(self) -> tuple[Callable[[str], Self], tuple[str]]: ... # type: ignore[override]
def getzoneinfofile_stream() -> BytesIO | None: ...