typehint a few globals (#36544)

This commit is contained in:
Harmen Stoppels 2023-03-31 08:32:56 +02:00 committed by GitHub
parent 98ac3acc92
commit b0e7b8c794
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 8 deletions

View file

@ -24,6 +24,7 @@
import warnings import warnings
from contextlib import closing, contextmanager from contextlib import closing, contextmanager
from gzip import GzipFile from gzip import GzipFile
from typing import Union
from urllib.error import HTTPError, URLError from urllib.error import HTTPError, URLError
import ruamel.yaml as yaml import ruamel.yaml as yaml
@ -502,7 +503,9 @@ def _binary_index():
#: Singleton binary_index instance #: 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): class NoOverwriteException(spack.error.SpackError):

View file

@ -5,6 +5,7 @@
"""Caches used by Spack to store data""" """Caches used by Spack to store data"""
import os import os
from typing import Union
import llnl.util.lang import llnl.util.lang
from llnl.util.filesystem import mkdirp from llnl.util.filesystem import mkdirp
@ -34,7 +35,9 @@ def _misc_cache():
#: Spack's cache for small data #: 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(): def fetch_cache_location():
@ -88,4 +91,6 @@ def symlink(self, mirror_ref):
#: Spack's local cache for downloaded source archives #: 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)

View file

@ -21,6 +21,7 @@
import tempfile import tempfile
from contextlib import contextmanager from contextlib import contextmanager
from itertools import chain from itertools import chain
from typing import Union
import archspec.cpu import archspec.cpu
@ -43,7 +44,9 @@
from spack.version import Version, VersionList, VersionRange, ver from spack.version import Version, VersionList, VersionRange, ver
#: impements rudimentary logic for ABI compatibility #: 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 @functools.total_ordering

View file

@ -36,7 +36,7 @@
import re import re
import sys import sys
from contextlib import contextmanager from contextlib import contextmanager
from typing import Dict, List, Optional from typing import Dict, List, Optional, Union
import ruamel.yaml as yaml import ruamel.yaml as yaml
from ruamel.yaml.error import MarkedYAMLError from ruamel.yaml.error import MarkedYAMLError
@ -838,7 +838,7 @@ def _config():
#: This is the singleton configuration instance for Spack. #: 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): def add_from_file(filename, scope=None):

View file

@ -1368,7 +1368,7 @@ def create(configuration):
#: Singleton repo path instance #: 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 # Add the finder to sys.meta_path
REPOS_FINDER = ReposFinder() REPOS_FINDER = ReposFinder()

View file

@ -20,6 +20,7 @@
import contextlib import contextlib
import os import os
import re import re
from typing import Union
import llnl.util.lang import llnl.util.lang
import llnl.util.tty as tty import llnl.util.tty as tty
@ -196,7 +197,7 @@ def _store():
#: Singleton store instance #: Singleton store instance
store = llnl.util.lang.Singleton(_store) store: Union[Store, llnl.util.lang.Singleton] = llnl.util.lang.Singleton(_store)
def _store_root(): def _store_root():