From ddf9d54dc16c2740d4102a250fa37af4719c0a42 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 14 Oct 2024 14:50:52 +0200 Subject: [PATCH] Bump icalendar to 6.0.1 (#12802) --- stubs/icalendar/@tests/stubtest_allowlist.txt | 9 ---- stubs/icalendar/icalendar/__init__.pyi | 6 +++ stubs/icalendar/icalendar/cal.pyi | 44 +++++++++++++++++++ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/stubs/icalendar/@tests/stubtest_allowlist.txt b/stubs/icalendar/@tests/stubtest_allowlist.txt index ec4c1ed43..5c91cf0a2 100644 --- a/stubs/icalendar/@tests/stubtest_allowlist.txt +++ b/stubs/icalendar/@tests/stubtest_allowlist.txt @@ -10,14 +10,5 @@ icalendar.Component.set_inline icalendar.cal.Component.get_inline icalendar.cal.Component.set_inline -# Runtime __all__ has extra items that don't exist. -icalendar.__all__ -icalendar.vTypesFactory -icalendar.parser.__all__ -icalendar.parser.tzid_from_dt -# Runtime __all__ is missing a comma, leading to incorrect items. -icalendar.parser_tools.__all__ -icalendar.parser_tools.ICAL_TYPEdata_encode - # Stubtest gets confused by multiple inheritance. icalendar.prop.vSkip.__new__ diff --git a/stubs/icalendar/icalendar/__init__.pyi b/stubs/icalendar/icalendar/__init__.pyi index 3f8daf59c..7aa257843 100644 --- a/stubs/icalendar/icalendar/__init__.pyi +++ b/stubs/icalendar/icalendar/__init__.pyi @@ -5,6 +5,8 @@ from .cal import ( ComponentFactory as ComponentFactory, Event as Event, FreeBusy as FreeBusy, + IncompleteComponent as IncompleteComponent, + InvalidCalendar as InvalidCalendar, Journal as Journal, Timezone as Timezone, TimezoneDaylight as TimezoneDaylight, @@ -25,6 +27,7 @@ from .prop import ( vFrequency as vFrequency, vGeo as vGeo, vInt as vInt, + vMonth as vMonth, vPeriod as vPeriod, vRecur as vRecur, vText as vText, @@ -81,4 +84,7 @@ __all__ = [ "version_tuple", "TypesFactory", "Component", + "vMonth", + "IncompleteComponent", + "InvalidCalendar", ] diff --git a/stubs/icalendar/icalendar/cal.pyi b/stubs/icalendar/icalendar/cal.pyi index 6e21942c6..2b1b1542f 100644 --- a/stubs/icalendar/icalendar/cal.pyi +++ b/stubs/icalendar/icalendar/cal.pyi @@ -2,6 +2,7 @@ import datetime from _typeshed import Incomplete, SupportsItems from collections.abc import Callable from typing import Any, ClassVar, Final, Literal, overload +from typing_extensions import TypeIs from .caselessdict import CaselessDict from .parser import Contentline, Contentlines @@ -22,6 +23,8 @@ __all__ = [ "Todo", "component_factory", "get_example", + "IncompleteComponent", + "InvalidCalendar", ] def get_example(component_directory: str, example_name: str) -> bytes: ... @@ -31,6 +34,9 @@ class ComponentFactory(CaselessDict[Incomplete]): INLINE: CaselessDict[int] +class InvalidCalendar(ValueError): ... +class IncompleteComponent(ValueError): ... + class Component(CaselessDict[Incomplete]): name: ClassVar[str | None] required: ClassVar[tuple[str, ...]] @@ -71,16 +77,54 @@ class Component(CaselessDict[Incomplete]): def to_ical(self, sorted: bool = True) -> bytes: ... def __eq__(self, other: Component) -> bool: ... # type: ignore[override] +# type_def is a TypeForm +def create_single_property(prop: str, value_attr: str, value_type: tuple[type, ...], type_def: Any, doc: str) -> property: ... +def is_date(dt: datetime.date) -> bool: ... # TypeIs[datetime.date and not datetime.datetime] +def is_datetime(dt: datetime.date) -> TypeIs[datetime.datetime]: ... + class Event(Component): name: ClassVar[Literal["VEVENT"]] @classmethod def example(cls, name: str) -> Event: ... + @property + def DTSTART(self) -> datetime.date | datetime.datetime | None: ... + @DTSTART.setter + def DTSTART(self, value: datetime.date | datetime.datetime | None) -> None: ... + @property + def DTEND(self) -> datetime.date | datetime.datetime | None: ... + @DTEND.setter + def DTEND(self, value: datetime.date | datetime.datetime | None) -> None: ... + @property + def DURATION(self) -> datetime.timedelta | None: ... + @DURATION.setter + def DURATION(self, value: datetime.timedelta | None) -> None: ... + @property + def duration(self) -> datetime.timedelta: ... + @property + def start(self) -> datetime.date | datetime.datetime: ... + @start.setter + def start(self, value: datetime.date | datetime.datetime | None) -> None: ... + @property + def end(self) -> datetime.date | datetime.datetime: ... + @end.setter + def end(self, value: datetime.date | datetime.datetime | None) -> None: ... class Todo(Component): name: ClassVar[Literal["VTODO"]] class Journal(Component): name: ClassVar[Literal["VJOURNAL"]] + @property + def DTSTART(self) -> datetime.date | datetime.datetime | None: ... + @DTSTART.setter + def DTSTART(self, value: datetime.date | datetime.datetime | None) -> None: ... + @property + def start(self) -> datetime.date | datetime.datetime: ... + @start.setter + def start(self, value: datetime.date | datetime.datetime | None) -> None: ... + end = start + @property + def duration(self) -> datetime.timedelta: ... class FreeBusy(Component): name: ClassVar[Literal["VFREEBUSY"]]