summaryrefslogtreecommitdiff
path: root/lib/spack/llnl
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-07-19 11:08:51 +0200
committerGitHub <noreply@github.com>2023-07-19 11:08:51 +0200
commita7f2abf9242ad321b410cc2f43b394856facba23 (patch)
tree83e9fc443e677f64ffee9d9f8d7cde1b08638456 /lib/spack/llnl
parenta99eaa954150778624f23459bafd49ce0397b099 (diff)
downloadspack-a7f2abf9242ad321b410cc2f43b394856facba23.tar.gz
spack-a7f2abf9242ad321b410cc2f43b394856facba23.tar.bz2
spack-a7f2abf9242ad321b410cc2f43b394856facba23.tar.xz
spack-a7f2abf9242ad321b410cc2f43b394856facba23.zip
Remove `LazyReference` from code (#38944)
A LazyReference object is a reference to an attribute of a lazily evaluated singleton. Its only purpose is to let developers use shorter names to refer to such attribute. This class does more harm than good, as it obfuscates the fact that we are using the attribute of a global object. Also, it can easily go out of sync with the singleton it refers to if, for instance, the singleton is updated but the references are not. This commit removes the LazyReference class entirely, and access the attributes explicitly passing through the global value to which they are attached.
Diffstat (limited to 'lib/spack/llnl')
-rw-r--r--lib/spack/llnl/util/lang.py21
1 files changed, 0 insertions, 21 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index ae75db621f..607b093de8 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -843,27 +843,6 @@ class Singleton:
return repr(self.instance)
-class LazyReference:
- """Lazily evaluated reference to part of a singleton."""
-
- def __init__(self, ref_function):
- self.ref_function = ref_function
-
- def __getattr__(self, name):
- if name == "ref_function":
- raise AttributeError()
- return getattr(self.ref_function(), name)
-
- def __getitem__(self, name):
- return self.ref_function()[name]
-
- def __str__(self):
- return str(self.ref_function())
-
- def __repr__(self):
- return repr(self.ref_function())
-
-
def load_module_from_file(module_name, module_path):
"""Loads a python module from the path of the corresponding file.