1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-22 00:10:16 +01:00
Files
core/script/hassfest/metadata.py
T
Franck Nijhof f0396aca8a Fix line length violations in script/ (#170759)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-17 10:30:02 -04:00

33 lines
1.1 KiB
Python

"""Package metadata validation."""
import tomllib
from homeassistant.const import REQUIRED_PYTHON_VER, __version__
from .model import Config, Integration
def validate(integrations: dict[str, Integration], config: Config) -> None:
"""Validate project metadata keys."""
metadata_path = config.root / "pyproject.toml"
data = tomllib.loads(metadata_path.read_text())
try:
if data["project"]["version"] != __version__:
config.add_error(
"metadata", f"'project.version' value does not match '{__version__}'"
)
except KeyError:
config.add_error("metadata", "No 'metadata.version' key found!")
required_py_version = f">={'.'.join(map(str, REQUIRED_PYTHON_VER))}"
try:
if data["project"]["requires-python"] != required_py_version:
config.add_error(
"metadata",
"'project.requires-python' value doesn't"
f" match '{required_py_version}'",
)
except KeyError:
config.add_error("metadata", "No 'options.python_requires' key found!")