Merge remote-tracking branch 'origin/dev' into jesserockz-2026-446

This commit is contained in:
Jesse Hills
2026-07-15 14:44:56 +12:00
52 changed files with 735 additions and 123 deletions
+7
View File
@@ -61,6 +61,13 @@ for path in components_dir.iterdir():
codeowners[f"esphome/components/{name}/*"].extend(comp.codeowners)
for platform_path in path.iterdir():
if platform_path.name == "__init__.py":
# `import pkg.__init__` is valid but distinct from `import pkg`: it re-executes
# the component's __init__.py as a second, separate module. That's harmless for
# components whose top-level code is idempotent, but not guaranteed in general
# (e.g. code that registers into a global registry with a duplicate check), so
# never treat __init__.py itself as a platform candidate.
continue
platform_name = platform_path.stem
platform = get_platform(platform_name, name)
if platform is None:
+33 -16
View File
@@ -263,22 +263,39 @@ def prepare_component_body(comp_data: dict, comp_name: str, comp_dir: Path) -> d
else {}
)
packages_value = comp_data.get("packages")
if isinstance(packages_value, dict):
common_bus_packages = get_common_bus_packages()
for pkg_name, pkg_value in list(packages_value.items()):
if pkg_name in common_bus_packages:
continue
if isinstance(pkg_value, yaml_util.IncludeFile):
pkg_value = pkg_value.load()
if isinstance(pkg_value, dict):
comp_data = merge_config(comp_data, pkg_value)
elif isinstance(packages_value, list):
for pkg_value in packages_value:
if isinstance(pkg_value, yaml_util.IncludeFile):
pkg_value = pkg_value.load()
if isinstance(pkg_value, dict):
comp_data = merge_config(comp_data, pkg_value)
# Expand component-specific package includes inline. A package include may
# itself pull in further component-specific packages (e.g. web_server's test
# includes common_v2, which includes common with the wifi/network config), so
# keep expanding until only common bus packages remain -- otherwise the nested
# includes are silently dropped when the packages key is removed below.
common_bus_packages = get_common_bus_packages()
while True:
packages_value = comp_data.get("packages")
expanded = False
if isinstance(packages_value, dict):
for pkg_name, pkg_value in list(packages_value.items()):
if pkg_name in common_bus_packages:
continue
# Drop before merging so a nested packages dict introduced by the
# include does not re-add this same key on the next iteration.
del packages_value[pkg_name]
if isinstance(pkg_value, yaml_util.IncludeFile):
pkg_value = pkg_value.load()
if isinstance(pkg_value, dict):
comp_data = merge_config(comp_data, pkg_value)
expanded = True
elif isinstance(packages_value, list):
# List-style packages never contain common bus packages, so expand
# them all and drop the key entirely.
comp_data.pop("packages", None)
for pkg_value in packages_value:
if isinstance(pkg_value, yaml_util.IncludeFile):
pkg_value = pkg_value.load()
if isinstance(pkg_value, dict):
comp_data = merge_config(comp_data, pkg_value)
expanded = True
if not expanded:
break
# Common bus packages are re-added once by the caller; drop them here.
comp_data.pop("packages", None)