spec.py: fix hash change due to None vs {} (#48854)

* Fix hash change due to None vs {}

* Enforce null for empty list of external_modules
This commit is contained in:
Harmen Stoppels 2025-02-05 09:48:00 +01:00 committed by Harmen Stoppels
parent 4a8ae59a9e
commit 4f80f07b9a

View File

@ -1538,9 +1538,8 @@ def __init__(
self._external_path = external_path
self.external_modules = Spec._format_module_list(external_modules)
# This attribute is used to store custom information for
# external specs. None signal that it was not set yet.
self.extra_attributes = None
# This attribute is used to store custom information for external specs.
self.extra_attributes: dict = {}
# This attribute holds the original build copy of the spec if it is
# deployed differently than it was built. None signals that the spec
@ -2252,16 +2251,11 @@ def to_node_dict(self, hash=ht.dag_hash):
)
if self.external:
if self.extra_attributes:
extra_attributes = syaml.sorted_dict(self.extra_attributes)
else:
extra_attributes = None
d["external"] = syaml.syaml_dict(
[
("path", self.external_path),
("module", self.external_modules),
("extra_attributes", extra_attributes),
("module", self.external_modules or None),
("extra_attributes", syaml.sorted_dict(self.extra_attributes)),
]
)