summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2023-03-31 08:32:56 +0200
committerGitHub <noreply@github.com>2023-03-31 08:32:56 +0200
commitb0e7b8c7949291527e0f9bd6d622d5afc665f29c (patch)
tree8b1ef1430b0d4f4755b43520e459d65276a1c56a /lib
parent98ac3acc928fd9aa557017e940a41eb61fa5db84 (diff)
downloadspack-b0e7b8c7949291527e0f9bd6d622d5afc665f29c.tar.gz
spack-b0e7b8c7949291527e0f9bd6d622d5afc665f29c.tar.bz2
spack-b0e7b8c7949291527e0f9bd6d622d5afc665f29c.tar.xz
spack-b0e7b8c7949291527e0f9bd6d622d5afc665f29c.zip
typehint a few globals (#36544)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/binary_distribution.py5
-rw-r--r--lib/spack/spack/caches.py9
-rw-r--r--lib/spack/spack/concretize.py5
-rw-r--r--lib/spack/spack/config.py4
-rw-r--r--lib/spack/spack/repo.py2
-rw-r--r--lib/spack/spack/store.py3
6 files changed, 20 insertions, 8 deletions
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 urllib.request
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 @@ class MirrorCache(object):
#: 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 platform
import tempfile
from contextlib import contextmanager
from itertools import chain
+from typing import Union
import archspec.cpu
@@ -43,7 +44,9 @@ from spack.package_prefs import PackagePrefs, is_spec_buildable, spec_externals
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 os
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 @@ debugging easier.
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():