mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
This commit is contained in:
@@ -703,6 +703,27 @@ def dependency_is_usable(
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _valid_dependency_entry(entry: dict, manifest_name: str) -> bool:
|
||||||
|
"""Whether a normalized entry carries a usable name and version.
|
||||||
|
|
||||||
|
The name must be a non-empty string (every consumer indexes or joins
|
||||||
|
it); a present version must be a string (a container would raise from
|
||||||
|
``set.add()``, an int fails opaquely inside the registry resolution).
|
||||||
|
Invalid entries warn naming the manifest.
|
||||||
|
"""
|
||||||
|
name = entry.get("name")
|
||||||
|
if (
|
||||||
|
isinstance(name, str)
|
||||||
|
and name
|
||||||
|
and ("version" not in entry or isinstance(entry["version"], str))
|
||||||
|
):
|
||||||
|
return True
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Ignoring unrecognized dependency entry %r of %s", entry, manifest_name
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def normalize_dependencies(
|
def normalize_dependencies(
|
||||||
dependencies: Any, manifest_name: str = "manifest"
|
dependencies: Any, manifest_name: str = "manifest"
|
||||||
) -> list[dict]:
|
) -> list[dict]:
|
||||||
@@ -732,23 +753,8 @@ def normalize_dependencies(
|
|||||||
entry.update(spec)
|
entry.update(spec)
|
||||||
else:
|
else:
|
||||||
entry["version"] = spec
|
entry["version"] = spec
|
||||||
if not isinstance(name := entry.get("name"), str) or not name:
|
if _valid_dependency_entry(entry, manifest_name):
|
||||||
_LOGGER.warning(
|
normalized.append(entry)
|
||||||
"Ignoring unrecognized dependency entry %r of %s",
|
|
||||||
entry,
|
|
||||||
manifest_name,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
if "version" in entry and not isinstance(entry["version"], str):
|
|
||||||
# A container would raise from set.add(); an int fails
|
|
||||||
# opaquely inside the registry resolution
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Ignoring unrecognized dependency entry %r of %s",
|
|
||||||
entry,
|
|
||||||
manifest_name,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
normalized.append(entry)
|
|
||||||
return normalized
|
return normalized
|
||||||
if not isinstance(dependencies, (list, tuple)):
|
if not isinstance(dependencies, (list, tuple)):
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
@@ -760,26 +766,8 @@ def normalize_dependencies(
|
|||||||
normalized = []
|
normalized = []
|
||||||
for entry in dependencies:
|
for entry in dependencies:
|
||||||
if isinstance(entry, dict):
|
if isinstance(entry, dict):
|
||||||
name = entry.get("name")
|
if _valid_dependency_entry(entry, manifest_name):
|
||||||
if not isinstance(name, str) or not name:
|
normalized.append(entry)
|
||||||
# A dependency name must be a non-empty string; every
|
|
||||||
# consumer indexes or joins it
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Ignoring unrecognized dependency entry %r of %s",
|
|
||||||
entry,
|
|
||||||
manifest_name,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
if "version" in entry and not isinstance(entry["version"], str):
|
|
||||||
# A container would raise from set.add(); an int fails
|
|
||||||
# opaquely inside the registry resolution
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Ignoring unrecognized dependency entry %r of %s",
|
|
||||||
entry,
|
|
||||||
manifest_name,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
normalized.append(entry)
|
|
||||||
elif isinstance(entry, str) and entry:
|
elif isinstance(entry, str) and entry:
|
||||||
# PIO also accepts a bare list of names ("dependencies": ["Wire"])
|
# PIO also accepts a bare list of names ("dependencies": ["Wire"])
|
||||||
normalized.append({"name": entry})
|
normalized.append({"name": entry})
|
||||||
|
|||||||
Reference in New Issue
Block a user