Add CalendarEntity checks to pylint plugin (#74228)

* Add CalendarEntity checks to pylint plugin

* adjust air_quality ignore

* Mark state property as final
This commit is contained in:
epenet 2022-06-30 19:00:34 +02:00 committed by GitHub
parent 7573dc34aa
commit 781e4571b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View File

@ -222,8 +222,9 @@ class CalendarEventDevice(Entity):
"description": event["description"],
}
@final
@property
def state(self) -> str | None:
def state(self) -> str:
"""Return the state of the calendar event."""
if (event := self.event) is None:
return STATE_OFF
@ -276,8 +277,9 @@ class CalendarEntity(Entity):
"description": event.description if event.description else "",
}
@final
@property
def state(self) -> str | None:
def state(self) -> str:
"""Return the state of the calendar event."""
if (event := self.event) is None:
return STATE_OFF

View File

@ -591,6 +591,7 @@ _TOGGLE_ENTITY_MATCH: list[TypeHintMatch] = [
),
]
_INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
# "air_quality": [], # ignored as deprecated
"alarm_control_panel": [
ClassTypeHintMatch(
base_class="Entity",
@ -717,6 +718,30 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
],
),
],
"calendar": [
ClassTypeHintMatch(
base_class="Entity",
matches=_ENTITY_MATCH,
),
ClassTypeHintMatch(
base_class="CalendarEntity",
matches=[
TypeHintMatch(
function_name="event",
return_type=["CalendarEvent", None],
),
TypeHintMatch(
function_name="async_get_events",
arg_types={
1: "HomeAssistant",
2: "datetime",
3: "datetime",
},
return_type="list[CalendarEvent]",
),
],
),
],
"cover": [
ClassTypeHintMatch(
base_class="Entity",