mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
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:
parent
4b6048b5e0
commit
6c8971f18a
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user