mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Migrate config-entry-unloading quality scale check from hassfest to pylint (#170720)
This commit is contained in:
@@ -13,7 +13,6 @@ from .model import Config, Integration, IntegrationType, ScaledQualityScaleTiers
|
||||
from .quality_scale_validation import (
|
||||
RuleValidationProtocol,
|
||||
action_setup,
|
||||
config_entry_unloading,
|
||||
config_flow,
|
||||
discovery,
|
||||
reauthentication_flow,
|
||||
@@ -58,9 +57,7 @@ ALL_RULES = [
|
||||
Rule("unique-config-entry", ScaledQualityScaleTiers.BRONZE, unique_config_entry),
|
||||
# SILVER
|
||||
Rule("action-exceptions", ScaledQualityScaleTiers.SILVER),
|
||||
Rule(
|
||||
"config-entry-unloading", ScaledQualityScaleTiers.SILVER, config_entry_unloading
|
||||
),
|
||||
Rule("config-entry-unloading", ScaledQualityScaleTiers.SILVER),
|
||||
Rule("docs-configuration-parameters", ScaledQualityScaleTiers.SILVER),
|
||||
Rule("docs-installation-parameters", ScaledQualityScaleTiers.SILVER),
|
||||
Rule("entity-unavailable", ScaledQualityScaleTiers.SILVER),
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
"""Enforce that the integration implements entry unloading.
|
||||
|
||||
https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/config-entry-unloading/
|
||||
"""
|
||||
|
||||
import ast
|
||||
|
||||
from script.hassfest import ast_parse_module
|
||||
from script.hassfest.model import Config, Integration
|
||||
|
||||
|
||||
def _has_unload_entry_function(module: ast.Module) -> bool:
|
||||
"""Test if the module defines `async_unload_entry` function."""
|
||||
return any(
|
||||
type(item) is ast.AsyncFunctionDef and item.name == "async_unload_entry"
|
||||
for item in module.body
|
||||
)
|
||||
|
||||
|
||||
def validate(
|
||||
config: Config, integration: Integration, *, rules_done: set[str]
|
||||
) -> list[str] | None:
|
||||
"""Validate that the integration has a config flow."""
|
||||
|
||||
init_file = integration.path / "__init__.py"
|
||||
init = ast_parse_module(init_file)
|
||||
|
||||
if not _has_unload_entry_function(init):
|
||||
return [
|
||||
"Integration does not support config entry unloading "
|
||||
"(is missing `async_unload_entry` in __init__.py)"
|
||||
]
|
||||
return None
|
||||
Reference in New Issue
Block a user