mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
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:
parent
7573dc34aa
commit
781e4571b2
@ -222,8 +222,9 @@ class CalendarEventDevice(Entity):
|
|||||||
"description": event["description"],
|
"description": event["description"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@final
|
||||||
@property
|
@property
|
||||||
def state(self) -> str | None:
|
def state(self) -> str:
|
||||||
"""Return the state of the calendar event."""
|
"""Return the state of the calendar event."""
|
||||||
if (event := self.event) is None:
|
if (event := self.event) is None:
|
||||||
return STATE_OFF
|
return STATE_OFF
|
||||||
@ -276,8 +277,9 @@ class CalendarEntity(Entity):
|
|||||||
"description": event.description if event.description else "",
|
"description": event.description if event.description else "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@final
|
||||||
@property
|
@property
|
||||||
def state(self) -> str | None:
|
def state(self) -> str:
|
||||||
"""Return the state of the calendar event."""
|
"""Return the state of the calendar event."""
|
||||||
if (event := self.event) is None:
|
if (event := self.event) is None:
|
||||||
return STATE_OFF
|
return STATE_OFF
|
||||||
|
@ -591,6 +591,7 @@ _TOGGLE_ENTITY_MATCH: list[TypeHintMatch] = [
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
_INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
_INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
||||||
|
# "air_quality": [], # ignored as deprecated
|
||||||
"alarm_control_panel": [
|
"alarm_control_panel": [
|
||||||
ClassTypeHintMatch(
|
ClassTypeHintMatch(
|
||||||
base_class="Entity",
|
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": [
|
"cover": [
|
||||||
ClassTypeHintMatch(
|
ClassTypeHintMatch(
|
||||||
base_class="Entity",
|
base_class="Entity",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user