Add parallel-updates rule to quality_scale validation (#132041)
parent
5bae000db5
commit
12be82fdbc
|
@ -16,6 +16,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from .coordinator import AcaiaConfigEntry
|
from .coordinator import AcaiaConfigEntry
|
||||||
from .entity import AcaiaEntity
|
from .entity import AcaiaEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(kw_only=True, frozen=True)
|
@dataclass(kw_only=True, frozen=True)
|
||||||
class AcaiaBinarySensorEntityDescription(BinarySensorEntityDescription):
|
class AcaiaBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||||
|
|
|
@ -21,6 +21,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from .coordinator import AcaiaConfigEntry
|
from .coordinator import AcaiaConfigEntry
|
||||||
from .entity import AcaiaEntity
|
from .entity import AcaiaEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(kw_only=True, frozen=True)
|
@dataclass(kw_only=True, frozen=True)
|
||||||
class AcaiaSensorEntityDescription(SensorEntityDescription):
|
class AcaiaSensorEntityDescription(SensorEntityDescription):
|
||||||
|
|
|
@ -33,7 +33,10 @@ rules:
|
||||||
entity-unavailable: done
|
entity-unavailable: done
|
||||||
integration-owner: done
|
integration-owner: done
|
||||||
log-when-unavailable: done
|
log-when-unavailable: done
|
||||||
parallel-updates: done
|
parallel-updates:
|
||||||
|
status: todo
|
||||||
|
comment: |
|
||||||
|
Does not set parallel-updates on button/switch action calls.
|
||||||
reauthentication-flow:
|
reauthentication-flow:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: |
|
comment: |
|
||||||
|
|
|
@ -25,6 +25,9 @@ from . import ElgatorConfigEntry
|
||||||
from .coordinator import ElgatoData, ElgatoDataUpdateCoordinator
|
from .coordinator import ElgatoData, ElgatoDataUpdateCoordinator
|
||||||
from .entity import ElgatoEntity
|
from .entity import ElgatoEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class ElgatoSensorEntityDescription(SensorEntityDescription):
|
class ElgatoSensorEntityDescription(SensorEntityDescription):
|
||||||
|
|
|
@ -30,6 +30,8 @@ from .coordinator import AutomowerDataUpdateCoordinator
|
||||||
from .entity import AutomowerBaseEntity
|
from .entity import AutomowerBaseEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
def entity_used_in(hass: HomeAssistant, entity_id: str) -> list[str]:
|
def entity_used_in(hass: HomeAssistant, entity_id: str) -> list[str]:
|
||||||
|
|
|
@ -15,6 +15,8 @@ from .coordinator import AutomowerDataUpdateCoordinator
|
||||||
from .entity import AutomowerBaseEntity
|
from .entity import AutomowerBaseEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
|
|
@ -8,6 +8,9 @@ from . import AutomowerConfigEntry
|
||||||
from .coordinator import AutomowerDataUpdateCoordinator
|
from .coordinator import AutomowerDataUpdateCoordinator
|
||||||
from .entity import AutomowerBaseEntity
|
from .entity import AutomowerBaseEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
|
|
@ -35,6 +35,8 @@ from .entity import (
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
ATTR_WORK_AREA_ID_ASSIGNMENT = "work_area_id_assignment"
|
ATTR_WORK_AREA_ID_ASSIGNMENT = "work_area_id_assignment"
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ from . import ImapConfigEntry
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import ImapDataUpdateCoordinator
|
from .coordinator import ImapDataUpdateCoordinator
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
IMAP_MAIL_COUNT_DESCRIPTION = SensorEntityDescription(
|
IMAP_MAIL_COUNT_DESCRIPTION = SensorEntityDescription(
|
||||||
key="imap_mail_count",
|
key="imap_mail_count",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
|
|
@ -30,6 +30,9 @@ from . import IronOSConfigEntry
|
||||||
from .const import OHM
|
from .const import OHM
|
||||||
from .entity import IronOSBaseEntity
|
from .entity import IronOSBaseEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
class PinecilSensor(StrEnum):
|
class PinecilSensor(StrEnum):
|
||||||
"""Pinecil Sensors."""
|
"""Pinecil Sensors."""
|
||||||
|
|
|
@ -40,6 +40,8 @@ from .coordinator import IstaCoordinator
|
||||||
from .util import IstaConsumptionType, IstaValueType, get_native_value, get_statistics
|
from .util import IstaConsumptionType, IstaValueType, get_native_value, get_statistics
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(kw_only=True, frozen=True)
|
@dataclass(kw_only=True, frozen=True)
|
||||||
|
|
|
@ -17,6 +17,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from .coordinator import LaMarzoccoConfigEntry
|
from .coordinator import LaMarzoccoConfigEntry
|
||||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class LaMarzoccoBinarySensorEntityDescription(
|
class LaMarzoccoBinarySensorEntityDescription(
|
||||||
|
|
|
@ -13,6 +13,9 @@ from homeassistant.util import dt as dt_util
|
||||||
from .coordinator import LaMarzoccoConfigEntry, LaMarzoccoUpdateCoordinator
|
from .coordinator import LaMarzoccoConfigEntry, LaMarzoccoUpdateCoordinator
|
||||||
from .entity import LaMarzoccoBaseEntity
|
from .entity import LaMarzoccoBaseEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
CALENDAR_KEY = "auto_on_off_schedule"
|
CALENDAR_KEY = "auto_on_off_schedule"
|
||||||
|
|
||||||
DAY_OF_WEEK = [
|
DAY_OF_WEEK = [
|
||||||
|
|
|
@ -19,6 +19,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from .coordinator import LaMarzoccoConfigEntry
|
from .coordinator import LaMarzoccoConfigEntry
|
||||||
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
from .entity import LaMarzoccoEntity, LaMarzoccoEntityDescription
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class LaMarzoccoSensorEntityDescription(
|
class LaMarzoccoSensorEntityDescription(
|
||||||
|
|
|
@ -39,7 +39,10 @@ rules:
|
||||||
entity-unavailable: done
|
entity-unavailable: done
|
||||||
integration-owner: done
|
integration-owner: done
|
||||||
log-when-unavailable: done
|
log-when-unavailable: done
|
||||||
parallel-updates: done
|
parallel-updates:
|
||||||
|
status: todo
|
||||||
|
comment: |
|
||||||
|
Does not set parallel-updates on notify platform.
|
||||||
reauthentication-flow:
|
reauthentication-flow:
|
||||||
status: todo
|
status: todo
|
||||||
comment: |
|
comment: |
|
||||||
|
|
|
@ -23,6 +23,9 @@ from .const import (
|
||||||
)
|
)
|
||||||
from .entity import MastodonEntity
|
from .entity import MastodonEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class MastodonSensorEntityDescription(SensorEntityDescription):
|
class MastodonSensorEntityDescription(SensorEntityDescription):
|
||||||
|
|
|
@ -18,6 +18,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from .coordinator import TedeeConfigEntry
|
from .coordinator import TedeeConfigEntry
|
||||||
from .entity import TedeeDescriptionEntity
|
from .entity import TedeeDescriptionEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class TedeeBinarySensorEntityDescription(
|
class TedeeBinarySensorEntityDescription(
|
||||||
|
|
|
@ -18,6 +18,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from .coordinator import TedeeConfigEntry
|
from .coordinator import TedeeConfigEntry
|
||||||
from .entity import TedeeDescriptionEntity
|
from .entity import TedeeDescriptionEntity
|
||||||
|
|
||||||
|
# Coordinator is used to centralize the data updates
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class TedeeSensorEntityDescription(SensorEntityDescription):
|
class TedeeSensorEntityDescription(SensorEntityDescription):
|
||||||
|
|
|
@ -18,6 +18,7 @@ from .quality_scale_validation import (
|
||||||
config_flow,
|
config_flow,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
discovery,
|
discovery,
|
||||||
|
parallel_updates,
|
||||||
reauthentication_flow,
|
reauthentication_flow,
|
||||||
reconfiguration_flow,
|
reconfiguration_flow,
|
||||||
runtime_data,
|
runtime_data,
|
||||||
|
@ -67,7 +68,7 @@ ALL_RULES = [
|
||||||
Rule("entity-unavailable", ScaledQualityScaleTiers.SILVER),
|
Rule("entity-unavailable", ScaledQualityScaleTiers.SILVER),
|
||||||
Rule("integration-owner", ScaledQualityScaleTiers.SILVER),
|
Rule("integration-owner", ScaledQualityScaleTiers.SILVER),
|
||||||
Rule("log-when-unavailable", ScaledQualityScaleTiers.SILVER),
|
Rule("log-when-unavailable", ScaledQualityScaleTiers.SILVER),
|
||||||
Rule("parallel-updates", ScaledQualityScaleTiers.SILVER),
|
Rule("parallel-updates", ScaledQualityScaleTiers.SILVER, parallel_updates),
|
||||||
Rule(
|
Rule(
|
||||||
"reauthentication-flow", ScaledQualityScaleTiers.SILVER, reauthentication_flow
|
"reauthentication-flow", ScaledQualityScaleTiers.SILVER, reauthentication_flow
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
"""Enforce that the integration sets PARALLEL_UPDATES constant.
|
||||||
|
|
||||||
|
https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/parallel-updates
|
||||||
|
"""
|
||||||
|
|
||||||
|
import ast
|
||||||
|
|
||||||
|
from homeassistant.const import Platform
|
||||||
|
from script.hassfest.model import Integration
|
||||||
|
|
||||||
|
|
||||||
|
def _has_parallel_updates_defined(module: ast.Module) -> bool:
|
||||||
|
"""Test if the module defines `PARALLEL_UPDATES` constant."""
|
||||||
|
return any(
|
||||||
|
type(item) is ast.Assign and item.targets[0].id == "PARALLEL_UPDATES"
|
||||||
|
for item in module.body
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate(integration: Integration) -> list[str] | None:
|
||||||
|
"""Validate that the integration sets PARALLEL_UPDATES constant."""
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
for platform in Platform:
|
||||||
|
module_file = integration.path / f"{platform}.py"
|
||||||
|
if not module_file.exists():
|
||||||
|
continue
|
||||||
|
module = ast.parse(module_file.read_text())
|
||||||
|
|
||||||
|
if not _has_parallel_updates_defined(module):
|
||||||
|
errors.append(
|
||||||
|
f"Integration does not set `PARALLEL_UPDATES` in {module_file}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return errors
|
Loading…
Reference in New Issue