Improve code quality of CalDav (#97570)

* Use keyword arguments when constructing `WebDavCalendarData`

* Use keyword arguments when constructing `WebDavCalendarEntity`

* Remove random newlines
This commit is contained in:
Andreas Lindhé 2023-08-05 20:44:26 +02:00 committed by GitHub
parent 4b6048b5e0
commit 6c8971f18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,7 +105,12 @@ def setup_platform(
entity_id = generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass)
calendar_devices.append(
WebDavCalendarEntity(
name, calendar, entity_id, days, True, cust_calendar[CONF_SEARCH]
name=name,
calendar=calendar,
entity_id=entity_id,
days=days,
all_day=True,
search=cust_calendar[CONF_SEARCH],
)
)
@ -126,7 +131,12 @@ class WebDavCalendarEntity(CalendarEntity):
def __init__(self, name, calendar, entity_id, days, all_day=False, search=None):
"""Create the WebDav Calendar Event Device."""
self.data = WebDavCalendarData(calendar, days, all_day, search)
self.data = WebDavCalendarData(
calendar=calendar,
days=days,
include_all_day=all_day,
search=search,
)
self.entity_id = entity_id
self._event: CalendarEvent | None = None
self._attr_name = name
@ -347,10 +357,8 @@ class WebDavCalendarData:
"""Return the end datetime as determined by dtend or duration."""
if hasattr(obj, "dtend"):
enddate = obj.dtend.value
elif hasattr(obj, "duration"):
enddate = obj.dtstart.value + obj.duration.value
else:
enddate = obj.dtstart.value + timedelta(days=1)