From fbb688af077f7327939b7d48aecf23767da14b61 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 5 Feb 2025 09:48:00 +0100 Subject: [PATCH] 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 --- lib/spack/spack/spec.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index fed7f28e9f9..8f8b445a1e8 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1527,9 +1527,8 @@ def __init__(self, spec_like=None, *, external_path=None, external_modules=None) 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 @@ -2351,15 +2350,10 @@ 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"] = { "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), } if not self._concrete: