diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 8a0536c006d5..6fd01163ea42 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -243,9 +243,10 @@ class timedelta: def __hash__(self) -> int: ... @disjoint_base -class datetime(date): +class datetime: min: ClassVar[datetime] max: ClassVar[datetime] + resolution: ClassVar[timedelta] def __new__( cls, year: SupportsIndex, @@ -259,6 +260,20 @@ class datetime(date): *, fold: int = 0, ) -> Self: ... + @classmethod + def today(cls) -> Self: ... + @classmethod + def fromordinal(cls, n: int, /) -> Self: ... + @classmethod + def fromisoformat(cls, date_string: str, /) -> Self: ... + @classmethod + def fromisocalendar(cls, year: int, week: int, day: int) -> Self: ... + @property + def year(self) -> int: ... + @property + def month(self) -> int: ... + @property + def day(self) -> int: ... @property def hour(self) -> int: ... @property @@ -271,15 +286,18 @@ class datetime(date): def tzinfo(self) -> _TzInfo | None: ... @property def fold(self) -> int: ... + def ctime(self) -> str: ... # On <3.12, the name of the first parameter in the pure-Python implementation # didn't match the name in the C implementation, # meaning it is only *safe* to pass it as a keyword argument on 3.12+ if sys.version_info >= (3, 12): @classmethod def fromtimestamp(cls, timestamp: float, tz: _TzInfo | None = None) -> Self: ... + def strftime(self, format: str) -> str: ... else: @classmethod def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo | None = None) -> Self: ... + def strftime(self, format: str, /) -> str: ... @classmethod @deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.timezone.utc)") @@ -332,15 +350,22 @@ class datetime(date): def utcoffset(self) -> timedelta | None: ... def tzname(self) -> str | None: ... def dst(self) -> timedelta | None: ... - def __le__(self, value: datetime, /) -> bool: ... # type: ignore[override] - def __lt__(self, value: datetime, /) -> bool: ... # type: ignore[override] - def __ge__(self, value: datetime, /) -> bool: ... # type: ignore[override] - def __gt__(self, value: datetime, /) -> bool: ... # type: ignore[override] + def timetuple(self) -> struct_time: ... + def toordinal(self) -> int: ... + def __le__(self, value: datetime, /) -> bool: ... + def __lt__(self, value: datetime, /) -> bool: ... + def __ge__(self, value: datetime, /) -> bool: ... + def __gt__(self, value: datetime, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ... - @overload # type: ignore[override] + def __add__(self, value: timedelta, /) -> Self: ... + def __radd__(self, value: timedelta, /) -> Self: ... + @overload def __sub__(self, value: Self, /) -> timedelta: ... @overload def __sub__(self, value: timedelta, /) -> Self: ... + def weekday(self) -> int: ... + def isoweekday(self) -> int: ... + def isocalendar(self) -> _IsoCalendarDate: ... datetime_CAPI: CapsuleType diff --git a/stubs/icalendar/icalendar/tools.pyi b/stubs/icalendar/icalendar/tools.pyi index d63d649f8041..087f6d40d13d 100644 --- a/stubs/icalendar/icalendar/tools.pyi +++ b/stubs/icalendar/icalendar/tools.pyi @@ -1,6 +1,6 @@ import datetime from typing import Final -from typing_extensions import TypeGuard, TypeIs, deprecated +from typing_extensions import Literal, TypeGuard, TypeIs, deprecated from pytz.tzinfo import BaseTzInfo @@ -17,8 +17,8 @@ class UIDGenerator: @deprecated("Use the Python standard library's :func:`uuid.uuid5` instead.") def uid(host_name: str = "example.com", unique: str = "") -> vText: ... -def is_date(dt: datetime.date) -> bool: ... # and not datetime.date -def is_datetime(dt: datetime.date) -> TypeIs[datetime.datetime]: ... +def is_date(dt: datetime.date) -> Literal[True]: ... # and not datetime.date +def is_datetime(dt: datetime.date) -> Literal[False]: ... def to_datetime(dt: datetime.date) -> datetime.datetime: ... def is_pytz(tz: datetime.tzinfo) -> TypeIs[BaseTzInfo]: ... def is_pytz_dt(dt: datetime.date) -> TypeGuard[datetime.datetime]: ... # and dt.tzinfo is BaseTZInfo diff --git a/stubs/pony/pony/orm/sqltranslation.pyi b/stubs/pony/pony/orm/sqltranslation.pyi index 816405de10c2..607b29571d69 100644 --- a/stubs/pony/pony/orm/sqltranslation.pyi +++ b/stubs/pony/pony/orm/sqltranslation.pyi @@ -620,7 +620,7 @@ class FuncTimedeltaMonad(FuncMonad): func: type[timedelta] def call(monad, days=None, seconds=None, microseconds=None, milliseconds=None, minutes=None, hours=None, weeks=None): ... -class FuncDatetimeMonad(FuncDateMonad): +class FuncDatetimeMonad(FuncMonad): func: type[datetime] def call(monad, year, month, day, hour=None, minute=None, second=None, microsecond=None): ... def call_now(monad): ...