mirror of
https://github.com/home-assistant/core.git
synced 2025-12-22 11:59:34 +00:00
Prevent NumberEntity and RestoreEntity inheritance (#93467)
This commit is contained in:
@@ -45,7 +45,7 @@ class HassInheritanceChecker(BaseChecker): # type: ignore[misc]
|
||||
|
||||
def visit_classdef(self, node: nodes.ClassDef) -> None:
|
||||
"""Apply relevant type hint checks on a ClassDef node."""
|
||||
if self._module_platform != "sensor":
|
||||
if self._module_platform not in {"number", "sensor"}:
|
||||
return
|
||||
|
||||
ancestors = [a.name for a in node.ancestors()]
|
||||
@@ -59,6 +59,16 @@ class HassInheritanceChecker(BaseChecker): # type: ignore[misc]
|
||||
node=node,
|
||||
args="SensorEntity and RestoreEntity should not be combined, please use RestoreSensor",
|
||||
)
|
||||
elif (
|
||||
"RestoreEntity" in ancestors
|
||||
and "NumberEntity" in ancestors
|
||||
and "RestoreNumber" not in ancestors
|
||||
):
|
||||
self.add_message(
|
||||
"hass-invalid-inheritance",
|
||||
node=node,
|
||||
args="NumberEntity and RestoreEntity should not be combined, please use RestoreNumber",
|
||||
)
|
||||
|
||||
|
||||
def register(linter: PyLinter) -> None:
|
||||
|
||||
Reference in New Issue
Block a user