diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index a406101d2c..233a587244 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -24,6 +24,7 @@ import warnings from contextlib import closing, contextmanager from gzip import GzipFile +from typing import Union from urllib.error import HTTPError, URLError import ruamel.yaml as yaml @@ -502,7 +503,9 @@ def _binary_index(): #: Singleton binary_index instance -binary_index = llnl.util.lang.Singleton(_binary_index) +binary_index: Union[BinaryCacheIndex, llnl.util.lang.Singleton] = llnl.util.lang.Singleton( + _binary_index +) class NoOverwriteException(spack.error.SpackError): diff --git a/lib/spack/spack/caches.py b/lib/spack/spack/caches.py index 69e8c44e26..20c8b9a169 100644 --- a/lib/spack/spack/caches.py +++ b/lib/spack/spack/caches.py @@ -5,6 +5,7 @@ """Caches used by Spack to store data""" import os +from typing import Union import llnl.util.lang from llnl.util.filesystem import mkdirp @@ -34,7 +35,9 @@ def _misc_cache(): #: Spack's cache for small data -misc_cache = llnl.util.lang.Singleton(_misc_cache) +misc_cache: Union[ + spack.util.file_cache.FileCache, llnl.util.lang.Singleton +] = llnl.util.lang.Singleton(_misc_cache) def fetch_cache_location(): @@ -88,4 +91,6 @@ def symlink(self, mirror_ref): #: Spack's local cache for downloaded source archives -fetch_cache = llnl.util.lang.Singleton(_fetch_cache) +fetch_cache: Union[ + spack.fetch_strategy.FsCache, llnl.util.lang.Singleton +] = llnl.util.lang.Singleton(_fetch_cache) diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 41a23994e3..3452e42738 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -21,6 +21,7 @@ import tempfile from contextlib import contextmanager from itertools import chain +from typing import Union import archspec.cpu @@ -43,7 +44,9 @@ from spack.version import Version, VersionList, VersionRange, ver #: impements rudimentary logic for ABI compatibility -_abi = llnl.util.lang.Singleton(lambda: spack.abi.ABI()) +_abi: Union[spack.abi.ABI, llnl.util.lang.Singleton] = llnl.util.lang.Singleton( + lambda: spack.abi.ABI() +) @functools.total_ordering diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index d31b1dd533..9154593656 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -36,7 +36,7 @@ import re import sys from contextlib import contextmanager -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Union import ruamel.yaml as yaml from ruamel.yaml.error import MarkedYAMLError @@ -838,7 +838,7 @@ def _config(): #: This is the singleton configuration instance for Spack. -config = llnl.util.lang.Singleton(_config) +config: Union[Configuration, llnl.util.lang.Singleton] = llnl.util.lang.Singleton(_config) def add_from_file(filename, scope=None): diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py index b9c3a39a20..1d62e83fb6 100644 --- a/lib/spack/spack/repo.py +++ b/lib/spack/spack/repo.py @@ -1368,7 +1368,7 @@ def create(configuration): #: Singleton repo path instance -path = llnl.util.lang.Singleton(_path) +path: Union[RepoPath, llnl.util.lang.Singleton] = llnl.util.lang.Singleton(_path) # Add the finder to sys.meta_path REPOS_FINDER = ReposFinder() diff --git a/lib/spack/spack/store.py b/lib/spack/spack/store.py index b588b76968..aa896c43ed 100644 --- a/lib/spack/spack/store.py +++ b/lib/spack/spack/store.py @@ -20,6 +20,7 @@ import contextlib import os import re +from typing import Union import llnl.util.lang import llnl.util.tty as tty @@ -196,7 +197,7 @@ def _store(): #: Singleton store instance -store = llnl.util.lang.Singleton(_store) +store: Union[Store, llnl.util.lang.Singleton] = llnl.util.lang.Singleton(_store) def _store_root():