mirror of
https://github.com/home-assistant/core.git
synced 2025-06-06 14:17:06 +00:00
Enable RUFF ICN001 for registries (#88875)
* Add issue_registry to RUFF extend aliases * Add area_registry to RUFF extend aliases * Add device_registry to RUFF extend aliases * Add entity_registry to RUFF extend aliases * Adjust scaffold
This commit is contained in:
parent
3f32c5d2ad
commit
bdbec491eb
@ -278,7 +278,11 @@ ignore = [
|
|||||||
|
|
||||||
[tool.ruff.flake8-import-conventions.extend-aliases]
|
[tool.ruff.flake8-import-conventions.extend-aliases]
|
||||||
voluptuous = "vol"
|
voluptuous = "vol"
|
||||||
|
"homeassistant.helpers.area_registry" = "ar"
|
||||||
"homeassistant.helpers.config_validation" = "cv"
|
"homeassistant.helpers.config_validation" = "cv"
|
||||||
|
"homeassistant.helpers.device_registry" = "dr"
|
||||||
|
"homeassistant.helpers.entity_registry" = "er"
|
||||||
|
"homeassistant.helpers.issue_registry" = "ir"
|
||||||
|
|
||||||
[tool.ruff.flake8-pytest-style]
|
[tool.ruff.flake8-pytest-style]
|
||||||
fixture-parentheses = false
|
fixture-parentheses = false
|
||||||
|
@ -13,8 +13,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import Context, HomeAssistant
|
from homeassistant.core import Context, HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ async def async_get_actions(
|
|||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, str]]:
|
) -> list[dict[str, str]]:
|
||||||
"""List device actions for NEW_NAME devices."""
|
"""List device actions for NEW_NAME devices."""
|
||||||
registry = entity_registry.async_get(hass)
|
registry = er.async_get(hass)
|
||||||
actions = []
|
actions = []
|
||||||
|
|
||||||
# TODO Read this comment and remove it.
|
# TODO Read this comment and remove it.
|
||||||
@ -44,7 +43,7 @@ async def async_get_actions(
|
|||||||
# return zha_device.device_actions
|
# return zha_device.device_actions
|
||||||
|
|
||||||
# Get all the integrations entities for this device
|
# Get all the integrations entities for this device
|
||||||
for entry in entity_registry.async_entries_for_device(registry, device_id):
|
for entry in er.async_entries_for_device(registry, device_id):
|
||||||
if entry.domain != DOMAIN:
|
if entry.domain != DOMAIN:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -14,8 +14,11 @@ from homeassistant.const import (
|
|||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import condition, config_validation as cv, entity_registry
|
from homeassistant.helpers import (
|
||||||
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
|
condition,
|
||||||
|
config_validation as cv,
|
||||||
|
entity_registry as er,
|
||||||
|
)
|
||||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
@ -23,7 +26,7 @@ from . import DOMAIN
|
|||||||
# TODO specify your supported condition types.
|
# TODO specify your supported condition types.
|
||||||
CONDITION_TYPES = {"is_on", "is_off"}
|
CONDITION_TYPES = {"is_on", "is_off"}
|
||||||
|
|
||||||
CONDITION_SCHEMA = DEVICE_CONDITION_BASE_SCHEMA.extend(
|
CONDITION_SCHEMA = cv.DEVICE_CONDITION_BASE_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||||
vol.Required(CONF_TYPE): vol.In(CONDITION_TYPES),
|
vol.Required(CONF_TYPE): vol.In(CONDITION_TYPES),
|
||||||
@ -35,11 +38,11 @@ async def async_get_conditions(
|
|||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, str]]:
|
) -> list[dict[str, str]]:
|
||||||
"""List device conditions for NEW_NAME devices."""
|
"""List device conditions for NEW_NAME devices."""
|
||||||
registry = entity_registry.async_get(hass)
|
registry = er.async_get(hass)
|
||||||
conditions = []
|
conditions = []
|
||||||
|
|
||||||
# Get all the integrations entities for this device
|
# Get all the integrations entities for this device
|
||||||
for entry in entity_registry.async_entries_for_device(registry, device_id):
|
for entry in er.async_entries_for_device(registry, device_id):
|
||||||
if entry.domain != DOMAIN:
|
if entry.domain != DOMAIN:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from homeassistant.const import (
|
|||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry
|
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
@ -41,7 +41,7 @@ async def async_get_triggers(
|
|||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
"""List device triggers for NEW_NAME devices."""
|
"""List device triggers for NEW_NAME devices."""
|
||||||
registry = entity_registry.async_get(hass)
|
registry = er.async_get(hass)
|
||||||
triggers = []
|
triggers = []
|
||||||
|
|
||||||
# TODO Read this comment and remove it.
|
# TODO Read this comment and remove it.
|
||||||
@ -52,7 +52,7 @@ async def async_get_triggers(
|
|||||||
# return zha_device.device_triggers
|
# return zha_device.device_triggers
|
||||||
|
|
||||||
# Get all the integrations entities for this device
|
# Get all the integrations entities for this device
|
||||||
for entry in entity_registry.async_entries_for_device(registry, device_id):
|
for entry in er.async_entries_for_device(registry, device_id):
|
||||||
if entry.domain != DOMAIN:
|
if entry.domain != DOMAIN:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user