Skip to content

Commit 05453b0

Browse files
authored
Update caldav to 1.2 (#9821)
Also add a few default values and replace some instances of Any with Incomplete.
1 parent 88506f0 commit 05453b0

3 files changed

Lines changed: 36 additions & 31 deletions

File tree

stubs/caldav/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "1.0.*"
1+
version = "1.2.*"
22
# also types-lxml and types-icalendar when those stubs are added
33
requires = ["types-requests", "types-vobject"]
44

stubs/caldav/caldav/davclient.pyi

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from _typeshed import Incomplete
12
from collections.abc import Iterable, Mapping
23
from types import TracebackType
3-
from typing import Any
44
from typing_extensions import Self, TypeAlias
55
from urllib.parse import ParseResult, SplitResult
66

@@ -12,7 +12,7 @@ from requests.structures import CaseInsensitiveDict
1212
from .lib.url import URL
1313
from .objects import Calendar, DAVObject, Principal
1414

15-
_Element: TypeAlias = Any # actually lxml.etree._Element
15+
_Element: TypeAlias = Incomplete # actually lxml.etree._Element
1616

1717
class DAVResponse:
1818
reason: str
@@ -26,7 +26,7 @@ class DAVResponse:
2626
def validate_status(self, status: str) -> None: ...
2727
def find_objects_and_props(self) -> None: ...
2828
def expand_simple_props(
29-
self, props: Iterable[Any] = ..., multi_value_props: Iterable[Any] = ..., xpath: str | None = ...
29+
self, props: Iterable[Incomplete] = ..., multi_value_props: Iterable[Incomplete] = ..., xpath: str | None = ...
3030
) -> dict[str, dict[str, str]]: ...
3131

3232
class DAVClient:
@@ -42,13 +42,14 @@ class DAVClient:
4242
def __init__(
4343
self,
4444
url: str,
45-
proxy: str | None = ...,
46-
username: str | None = ...,
47-
password: str | None = ...,
48-
auth: AuthBase | None = ...,
49-
timeout: _Timeout | None = ...,
50-
ssl_verify_cert: bool | str = ...,
51-
ssl_cert: str | tuple[str, str] | None = ...,
45+
proxy: str | None = None,
46+
username: str | None = None,
47+
password: str | None = None,
48+
auth: AuthBase | None = None,
49+
timeout: _Timeout | None = None,
50+
ssl_verify_cert: bool | str = True,
51+
ssl_cert: str | tuple[str, str] | None = None,
52+
headers: dict[str, str] = ...,
5253
) -> None: ...
5354
def __enter__(self) -> Self: ...
5455
def __exit__(
@@ -61,8 +62,8 @@ class DAVClient:
6162
parent: DAVObject | None = ...,
6263
name: str | None = ...,
6364
id: str | None = ...,
64-
props: Mapping[Any, Any] = ...,
65-
**extra: Any,
65+
props: Mapping[Incomplete, Incomplete] = ...,
66+
**extra: Incomplete,
6667
) -> Calendar: ...
6768
def check_dav_support(self) -> str | None: ...
6869
def check_cdav_support(self) -> bool: ...

stubs/caldav/caldav/objects.pyi

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
from _typeshed import Incomplete
33
from collections.abc import Iterable, Iterator, Mapping, Sequence
4-
from typing import Any, TypeVar, overload
4+
from typing import TypeVar, overload
55
from typing_extensions import Literal, Self, TypeAlias
66
from urllib.parse import ParseResult, SplitResult
77

@@ -14,30 +14,30 @@ from .lib.url import URL
1414
_CC = TypeVar("_CC", bound=CalendarObjectResource)
1515
# Actually "type[Todo] | type[Event] | type[Journal]", but mypy doesn't like that.
1616
_CompClass: TypeAlias = type[CalendarObjectResource]
17-
_VCalAddress: TypeAlias = Any # actually icalendar.vCalAddress
17+
_VCalAddress: TypeAlias = Incomplete # actually icalendar.vCalAddress
1818

1919
class DAVObject:
2020
id: str | None
2121
url: URL | None
2222
client: DAVClient | None
2323
parent: DAVObject | None
2424
name: str | None
25-
props: Mapping[Any, Any]
26-
extra_init_options: dict[str, Any]
25+
props: Mapping[Incomplete, Incomplete]
26+
extra_init_options: dict[str, Incomplete]
2727
def __init__(
2828
self,
2929
client: DAVClient | None = ...,
3030
url: str | ParseResult | SplitResult | URL | None = ...,
3131
parent: DAVObject | None = ...,
3232
name: str | None = ...,
3333
id: str | None = ...,
34-
props: Mapping[Any, Any] | None = ...,
35-
**extra: Any,
34+
props: Mapping[Incomplete, Incomplete] | None = ...,
35+
**extra: Incomplete,
3636
) -> None: ...
3737
@property
3838
def canonical_url(self) -> str: ...
39-
def children(self, type: str | None = ...) -> list[tuple[URL, Any, Any]]: ...
40-
def get_property(self, prop, use_cached: bool = ..., **passthrough) -> Any | None: ...
39+
def children(self, type: str | None = ...) -> list[tuple[URL, Incomplete, Incomplete]]: ...
40+
def get_property(self, prop, use_cached: bool = ..., **passthrough) -> Incomplete | None: ...
4141
def get_properties(
4242
self, props: Incomplete | None = ..., depth: int = ..., parse_response_xml: bool = ..., parse_props: bool = ...
4343
): ...
@@ -58,7 +58,7 @@ class Principal(DAVObject):
5858
def make_calendar(
5959
self, name: str | None = ..., cal_id: str | None = ..., supported_calendar_component_set: Incomplete | None = ...
6060
) -> Calendar: ...
61-
def calendar(self, name: str | None = ..., cal_id: str | None = ...) -> Calendar: ...
61+
def calendar(self, name: str | None = None, cal_id: str | None = None, cal_url: str | None = None) -> Calendar: ...
6262
def get_vcal_address(self) -> _VCalAddress: ...
6363
calendar_home_set: CalendarSet # can also be set to anything URL.objectify() accepts
6464
def freebusy_request(self, dtstart, dtend, attendees): ...
@@ -67,12 +67,16 @@ class Principal(DAVObject):
6767
def schedule_outbox(self) -> ScheduleOutbox: ...
6868

6969
class Calendar(DAVObject):
70-
def get_supported_components(self) -> list[Any]: ...
70+
def get_supported_components(self) -> list[Incomplete]: ...
7171
def save_with_invites(self, ical: str, attendees, **attendeeoptions) -> None: ...
72-
def save_event(self, ical: str | None = ..., no_overwrite: bool = ..., no_create: bool = ..., **ical_data: Any) -> Event: ...
73-
def save_todo(self, ical: str | None = ..., no_overwrite: bool = ..., no_create: bool = ..., **ical_data: Any) -> Todo: ...
72+
def save_event(
73+
self, ical: str | None = ..., no_overwrite: bool = ..., no_create: bool = ..., **ical_data: Incomplete
74+
) -> Event: ...
75+
def save_todo(
76+
self, ical: str | None = ..., no_overwrite: bool = ..., no_create: bool = ..., **ical_data: Incomplete
77+
) -> Todo: ...
7478
def save_journal(
75-
self, ical: str | None = ..., no_overwrite: bool = ..., no_create: bool = ..., **ical_data: Any
79+
self, ical: str | None = ..., no_overwrite: bool = ..., no_create: bool = ..., **ical_data: Incomplete
7680
) -> Journal: ...
7781
add_event = save_event
7882
add_todo = save_todo
@@ -192,10 +196,10 @@ class ScheduleOutbox(ScheduleMailbox):
192196

193197
class SynchronizableCalendarObjectCollection:
194198
def __init__(self, calendar, objects, sync_token) -> None: ...
195-
def __iter__(self) -> Iterator[Any]: ...
199+
def __iter__(self) -> Iterator[Incomplete]: ...
196200
def __len__(self) -> int: ...
197201
def objects_by_url(self): ...
198-
def sync(self) -> tuple[Any, Any]: ...
202+
def sync(self) -> tuple[Incomplete, Incomplete]: ...
199203

200204
class CalendarObjectResource(DAVObject):
201205
def __init__(
@@ -216,7 +220,7 @@ class CalendarObjectResource(DAVObject):
216220
def decline_invite(self, calendar: Incomplete | None = ...) -> None: ...
217221
def tentatively_accept_invite(self, calendar: Incomplete | None = ...) -> None: ...
218222
def copy(self, keep_uid: bool = ..., new_parent: Incomplete | None = ...) -> Self: ...
219-
def load(self) -> Self: ...
223+
def load(self, only_if_unloaded: bool = False) -> Self: ...
220224
def change_attendee_status(self, attendee: Incomplete | None = ..., **kwargs) -> None: ...
221225
def save(
222226
self,
@@ -227,9 +231,9 @@ class CalendarObjectResource(DAVObject):
227231
if_schedule_tag_match: bool = ...,
228232
) -> Self: ...
229233
def get_duration(self) -> datetime.timedelta: ...
230-
data: Any
234+
data: Incomplete
231235
vobject_instance: VBase
232-
icalendar_instance: Any
236+
icalendar_instance: Incomplete
233237
instance: VBase
234238

235239
class Event(CalendarObjectResource): ...

0 commit comments

Comments
 (0)