Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions stdlib/datetime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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)")
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions stubs/icalendar/icalendar/tools.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stubs/pony/pony/orm/sqltranslation.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
Loading