mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
hassfest detect built-in domain override for custom integrations (#49845)
This commit is contained in:
parent
b7184b669f
commit
52f3a7249f
@ -1,6 +1,7 @@
|
|||||||
"""Manifest validation."""
|
"""Manifest validation."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -8,7 +9,7 @@ from voluptuous.humanize import humanize_error
|
|||||||
|
|
||||||
from homeassistant.loader import validate_custom_integration_version
|
from homeassistant.loader import validate_custom_integration_version
|
||||||
|
|
||||||
from .model import Integration
|
from .model import Config, Integration
|
||||||
|
|
||||||
DOCUMENTATION_URL_SCHEMA = "https"
|
DOCUMENTATION_URL_SCHEMA = "https"
|
||||||
DOCUMENTATION_URL_HOST = "www.home-assistant.io"
|
DOCUMENTATION_URL_HOST = "www.home-assistant.io"
|
||||||
@ -227,7 +228,7 @@ def validate_version(integration: Integration):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def validate_manifest(integration: Integration):
|
def validate_manifest(integration: Integration, core_components_dir: Path) -> None:
|
||||||
"""Validate manifest."""
|
"""Validate manifest."""
|
||||||
if not integration.manifest:
|
if not integration.manifest:
|
||||||
return
|
return
|
||||||
@ -245,6 +246,14 @@ def validate_manifest(integration: Integration):
|
|||||||
if integration.manifest["domain"] != integration.path.name:
|
if integration.manifest["domain"] != integration.path.name:
|
||||||
integration.add_error("manifest", "Domain does not match dir name")
|
integration.add_error("manifest", "Domain does not match dir name")
|
||||||
|
|
||||||
|
if (
|
||||||
|
not integration.core
|
||||||
|
and (core_components_dir / integration.manifest["domain"]).exists()
|
||||||
|
):
|
||||||
|
integration.add_warning(
|
||||||
|
"manifest", "Domain collides with built-in core integration"
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
integration.manifest["domain"] in NO_IOT_CLASS
|
integration.manifest["domain"] in NO_IOT_CLASS
|
||||||
and "iot_class" in integration.manifest
|
and "iot_class" in integration.manifest
|
||||||
@ -261,7 +270,8 @@ def validate_manifest(integration: Integration):
|
|||||||
validate_version(integration)
|
validate_version(integration)
|
||||||
|
|
||||||
|
|
||||||
def validate(integrations: dict[str, Integration], config):
|
def validate(integrations: dict[str, Integration], config: Config) -> None:
|
||||||
"""Handle all integrations manifests."""
|
"""Handle all integrations manifests."""
|
||||||
|
core_components_dir = config.root / "homeassistant/components"
|
||||||
for integration in integrations.values():
|
for integration in integrations.values():
|
||||||
validate_manifest(integration)
|
validate_manifest(integration, core_components_dir)
|
||||||
|
@ -100,7 +100,7 @@ class Integration:
|
|||||||
"""Add an error."""
|
"""Add an error."""
|
||||||
self.errors.append(Error(*args, **kwargs))
|
self.errors.append(Error(*args, **kwargs))
|
||||||
|
|
||||||
def add_warning(self, *args, **kwargs):
|
def add_warning(self, *args: Any, **kwargs: Any) -> None:
|
||||||
"""Add an warning."""
|
"""Add an warning."""
|
||||||
self.warnings.append(Error(*args, **kwargs))
|
self.warnings.append(Error(*args, **kwargs))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user