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:
epenet 2023-03-01 18:40:26 +01:00 committed by GitHub
parent 3f32c5d2ad
commit bdbec491eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View file

@ -278,7 +278,11 @@ ignore = [
[tool.ruff.flake8-import-conventions.extend-aliases]
voluptuous = "vol"
"homeassistant.helpers.area_registry" = "ar"
"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]
fixture-parentheses = false

View file

@ -13,8 +13,7 @@ from homeassistant.const import (
SERVICE_TURN_ON,
)
from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import config_validation as cv, entity_registry as er
from . import DOMAIN
@ -33,7 +32,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for NEW_NAME devices."""
registry = entity_registry.async_get(hass)
registry = er.async_get(hass)
actions = []
# TODO Read this comment and remove it.
@ -44,7 +43,7 @@ async def async_get_actions(
# return zha_device.device_actions
# 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:
continue

View file

@ -14,8 +14,11 @@ from homeassistant.const import (
STATE_ON,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
from . import DOMAIN
@ -23,7 +26,7 @@ from . import DOMAIN
# TODO specify your supported condition types.
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_TYPE): vol.In(CONDITION_TYPES),
@ -35,11 +38,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for NEW_NAME devices."""
registry = entity_registry.async_get(hass)
registry = er.async_get(hass)
conditions = []
# 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:
continue

View file

@ -21,7 +21,7 @@ from homeassistant.const import (
STATE_ON,
)
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 . import DOMAIN
@ -41,7 +41,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for NEW_NAME devices."""
registry = entity_registry.async_get(hass)
registry = er.async_get(hass)
triggers = []
# TODO Read this comment and remove it.
@ -52,7 +52,7 @@ async def async_get_triggers(
# return zha_device.device_triggers
# 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:
continue