Skip to content

Commit 77dca49

Browse files
Fix pylint plugin for vacuum entity (home-assistant#146467)
* Clean out legacy VacuumEntity from pylint plugins * Fix * Fix pylint for vacuum * More fixes * Revert partial * Add back state
1 parent 1baba8b commit 77dca49

File tree

4 files changed

+20
-72
lines changed

4 files changed

+20
-72
lines changed

homeassistant/components/lg_thinq/vacuum.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from enum import StrEnum
66
import logging
7+
from typing import Any
78

89
from thinqconnect import DeviceType
910
from thinqconnect.integration import ExtendedProperty
@@ -154,7 +155,7 @@ async def async_pause(self, **kwargs) -> None:
154155
)
155156
)
156157

157-
async def async_return_to_base(self, **kwargs) -> None:
158+
async def async_return_to_base(self, **kwargs: Any) -> None:
158159
"""Return device to dock."""
159160
_LOGGER.debug(
160161
"[%s:%s] async_return_to_base",

pylint/plugins/hass_enforce_class_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"todo": {"TodoListEntity"},
7171
"tts": {"TextToSpeechEntity"},
7272
"update": {"UpdateEntity", "UpdateEntityDescription"},
73-
"vacuum": {"StateVacuumEntity", "VacuumEntity", "VacuumEntityDescription"},
73+
"vacuum": {"StateVacuumEntity", "VacuumEntityDescription"},
7474
"wake_word": {"WakeWordDetectionEntity"},
7575
"water_heater": {"WaterHeaterEntity"},
7676
"weather": {

pylint/plugins/hass_enforce_type_hints.py

Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,12 +2789,12 @@ class ClassTypeHintMatch:
27892789
matches=_RESTORE_ENTITY_MATCH,
27902790
),
27912791
ClassTypeHintMatch(
2792-
base_class="ToggleEntity",
2793-
matches=_TOGGLE_ENTITY_MATCH,
2794-
),
2795-
ClassTypeHintMatch(
2796-
base_class="_BaseVacuum",
2792+
base_class="StateVacuumEntity",
27972793
matches=[
2794+
TypeHintMatch(
2795+
function_name="state",
2796+
return_type=["str", None],
2797+
),
27982798
TypeHintMatch(
27992799
function_name="battery_level",
28002800
return_type=["int", None],
@@ -2821,6 +2821,16 @@ class ClassTypeHintMatch:
28212821
return_type=None,
28222822
has_async_counterpart=True,
28232823
),
2824+
TypeHintMatch(
2825+
function_name="start",
2826+
return_type=None,
2827+
has_async_counterpart=True,
2828+
),
2829+
TypeHintMatch(
2830+
function_name="pause",
2831+
return_type=None,
2832+
has_async_counterpart=True,
2833+
),
28242834
TypeHintMatch(
28252835
function_name="return_to_base",
28262836
kwargs_type="Any",
@@ -2860,63 +2870,6 @@ class ClassTypeHintMatch:
28602870
),
28612871
],
28622872
),
2863-
ClassTypeHintMatch(
2864-
base_class="VacuumEntity",
2865-
matches=[
2866-
TypeHintMatch(
2867-
function_name="status",
2868-
return_type=["str", None],
2869-
),
2870-
TypeHintMatch(
2871-
function_name="start_pause",
2872-
kwargs_type="Any",
2873-
return_type=None,
2874-
has_async_counterpart=True,
2875-
),
2876-
TypeHintMatch(
2877-
function_name="async_pause",
2878-
return_type=None,
2879-
),
2880-
TypeHintMatch(
2881-
function_name="async_start",
2882-
return_type=None,
2883-
),
2884-
],
2885-
),
2886-
ClassTypeHintMatch(
2887-
base_class="StateVacuumEntity",
2888-
matches=[
2889-
TypeHintMatch(
2890-
function_name="state",
2891-
return_type=["str", None],
2892-
),
2893-
TypeHintMatch(
2894-
function_name="start",
2895-
return_type=None,
2896-
has_async_counterpart=True,
2897-
),
2898-
TypeHintMatch(
2899-
function_name="pause",
2900-
return_type=None,
2901-
has_async_counterpart=True,
2902-
),
2903-
TypeHintMatch(
2904-
function_name="async_turn_on",
2905-
kwargs_type="Any",
2906-
return_type=None,
2907-
),
2908-
TypeHintMatch(
2909-
function_name="async_turn_off",
2910-
kwargs_type="Any",
2911-
return_type=None,
2912-
),
2913-
TypeHintMatch(
2914-
function_name="async_toggle",
2915-
kwargs_type="Any",
2916-
return_type=None,
2917-
),
2918-
],
2919-
),
29202873
],
29212874
"water_heater": [
29222875
ClassTypeHintMatch(

tests/pylint/test_enforce_type_hints.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,17 +1161,11 @@ def test_vacuum_entity(linter: UnittestLinter, type_hint_checker: BaseChecker) -
11611161
class Entity():
11621162
pass
11631163
1164-
class ToggleEntity(Entity):
1165-
pass
1166-
1167-
class _BaseVacuum(Entity):
1168-
pass
1169-
1170-
class VacuumEntity(_BaseVacuum, ToggleEntity):
1164+
class StateVacuumEntity(Entity):
11711165
pass
11721166
11731167
class MyVacuum( #@
1174-
VacuumEntity
1168+
StateVacuumEntity
11751169
):
11761170
def send_command(
11771171
self,

0 commit comments

Comments
 (0)