diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2023-02-16 22:06:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 23:06:12 -0600 |
commit | 603569e321013a1a63a637813c94c2834d0a0023 (patch) | |
tree | 366d3ba04458bb748c1f494e270401a56c10a7f2 /lib/spack | |
parent | b9358099488b6c9851e28ca912c8be246178974a (diff) | |
download | spack-603569e321013a1a63a637813c94c2834d0a0023.tar.gz spack-603569e321013a1a63a637813c94c2834d0a0023.tar.bz2 spack-603569e321013a1a63a637813c94c2834d0a0023.tar.xz spack-603569e321013a1a63a637813c94c2834d0a0023.zip |
Style: black 23, skip magic trailing comma (#35351)
* Style: black 23, skip magic trailing commas
* isort should use same line length as black
* Fix unused import
* Update version of black used in CI
* Update new packages
* Update new packages
Diffstat (limited to 'lib/spack')
158 files changed, 367 insertions, 1650 deletions
diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py index fdf40f79cb..2b04fa642f 100644 --- a/lib/spack/docs/conf.py +++ b/lib/spack/docs/conf.py @@ -89,6 +89,7 @@ sphinx_apidoc(apidoc_args + ["_spack_root/lib/spack/llnl"]) # Enable todo items todo_include_todos = True + # # Disable duplicate cross-reference warnings. # @@ -353,9 +354,7 @@ latex_elements = { # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ("index", "Spack.tex", "Spack Documentation", "Todd Gamblin", "manual"), -] +latex_documents = [("index", "Spack.tex", "Spack Documentation", "Todd Gamblin", "manual")] # The name of an image file (relative to this directory) to place at the top of # the title page. @@ -402,7 +401,7 @@ texinfo_documents = [ "Spack", "One line description of project.", "Miscellaneous", - ), + ) ] # Documents to append as an appendix to all manuals. @@ -418,6 +417,4 @@ texinfo_documents = [ # -- Extension configuration ------------------------------------------------- # sphinx.ext.intersphinx -intersphinx_mapping = { - "python": ("https://docs.python.org/3", None), -} +intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index b39a17b52a..330ee35911 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -268,7 +268,6 @@ def filter_file( regex = re.escape(regex) filenames = path_to_os_path(*filenames) for filename in filenames: - msg = 'FILTER FILE: {0} [replacing "{1}"]' tty.debug(msg.format(filename, regex)) @@ -1220,7 +1219,6 @@ def traverse_tree( # target is relative to the link, then that may not resolve properly # relative to our cwd - see resolve_link_target_relative_to_the_link if os.path.isdir(source_child) and (follow_links or not os.path.islink(source_child)): - # When follow_nonexisting isn't set, don't descend into dirs # in source that do not exist in dest if follow_nonexisting or os.path.exists(dest_child): @@ -1662,7 +1660,6 @@ def find(root, files, recursive=True): @system_path_filter def _find_recursive(root, search_files): - # The variable here is **on purpose** a defaultdict. The idea is that # we want to poke the filesystem as little as possible, but still maintain # stability in the order of the answer. Thus we are recording each library diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py index b03558b4f7..2f484cb874 100644 --- a/lib/spack/llnl/util/lang.py +++ b/lib/spack/llnl/util/lang.py @@ -198,7 +198,7 @@ def memoized(func): except TypeError as e: # TypeError is raised when indexing into a dict if the key is unhashable. raise UnhashableArguments( - "args + kwargs '{}' was not hashable for function '{}'".format(key, func.__name__), + "args + kwargs '{}' was not hashable for function '{}'".format(key, func.__name__) ) from e return _memoized_function @@ -237,6 +237,7 @@ def decorator_with_or_without_args(decorator): @decorator """ + # See https://stackoverflow.com/questions/653368 for more on this @functools.wraps(decorator) def new_dec(*args, **kwargs): @@ -990,8 +991,7 @@ def enum(**kwargs): def stable_partition( - input_iterable: Iterable, - predicate_fn: Callable[[Any], bool], + input_iterable: Iterable, predicate_fn: Callable[[Any], bool] ) -> Tuple[List[Any], List[Any]]: """Partition the input iterable according to a custom predicate. @@ -1104,11 +1104,7 @@ class GroupedExceptionForwarder(object): def __exit__(self, exc_type, exc_value, tb): if exc_value is not None: - self._handler._receive_forwarded( - self._context, - exc_value, - traceback.format_tb(tb), - ) + self._handler._receive_forwarded(self._context, exc_value, traceback.format_tb(tb)) # Suppress any exception from being re-raised: # https://docs.python.org/3/reference/datamodel.html#object.__exit__. diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py index c723fe8051..ba9a627587 100644 --- a/lib/spack/llnl/util/tty/__init__.py +++ b/lib/spack/llnl/util/tty/__init__.py @@ -108,7 +108,6 @@ class SuppressOutput: """Class for disabling output in a scope using 'with' keyword""" def __init__(self, msg_enabled=True, warn_enabled=True, error_enabled=True): - self._msg_enabled_initial = _msg_enabled self._warn_enabled_initial = _warn_enabled self._error_enabled_initial = _error_enabled diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py index 9a3ee46450..f2aed3d5b9 100644 --- a/lib/spack/llnl/util/tty/log.py +++ b/lib/spack/llnl/util/tty/log.py @@ -161,10 +161,7 @@ class keyboard_input(object): def _get_canon_echo_flags(self): """Get current termios canonical and echo settings.""" cfg = termios.tcgetattr(self.stream) - return ( - bool(cfg[3] & termios.ICANON), - bool(cfg[3] & termios.ECHO), - ) + return (bool(cfg[3] & termios.ICANON), bool(cfg[3] & termios.ECHO)) def _enable_keyboard_input(self): """Disable canonical input and echoing on ``self.stream``.""" diff --git a/lib/spack/llnl/util/tty/pty.py b/lib/spack/llnl/util/tty/pty.py index 1b5626f4ff..db959b3cff 100644 --- a/lib/spack/llnl/util/tty/pty.py +++ b/lib/spack/llnl/util/tty/pty.py @@ -77,10 +77,7 @@ class ProcessController(object): def get_canon_echo_attrs(self): """Get echo and canon attributes of the terminal of controller_fd.""" cfg = termios.tcgetattr(self.controller_fd) - return ( - bool(cfg[3] & termios.ICANON), - bool(cfg[3] & termios.ECHO), - ) + return (bool(cfg[3] & termios.ICANON), bool(cfg[3] & termios.ECHO)) def horizontal_line(self, name): """Labled horizontal line for debugging.""" @@ -92,11 +89,7 @@ class ProcessController(object): if self.debug: canon, echo = self.get_canon_echo_attrs() sys.stderr.write( - "canon: %s, echo: %s\n" - % ( - "on" if canon else "off", - "on" if echo else "off", - ) + "canon: %s, echo: %s\n" % ("on" if canon else "off", "on" if echo else "off") ) sys.stderr.write("input: %s\n" % self.input_on()) sys.stderr.write("bg: %s\n" % self.background()) diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py index a6e0a88b9c..441ec33136 100644 --- a/lib/spack/spack/audit.py +++ b/lib/spack/spack/audit.py @@ -321,8 +321,7 @@ def _check_patch_urls(pkgs, error_cls): errors.append( error_cls( "patch URL in package {0} must end with {1}".format( - pkg_cls.name, - full_index_arg, + pkg_cls.name, full_index_arg ), [patch.url], ) diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index 1e1085707e..01f428c633 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -210,10 +210,7 @@ class BinaryCacheIndex(object): break else: self._mirrors_for_spec[dag_hash].append( - { - "mirror_url": mirror_url, - "spec": indexed_spec, - } + {"mirror_url": mirror_url, "spec": indexed_spec} ) finally: shutil.rmtree(tmpdir) @@ -296,10 +293,7 @@ class BinaryCacheIndex(object): break else: current_list.append( - { - "mirror_url": new_entry["mirror_url"], - "spec": new_entry["spec"], - } + {"mirror_url": new_entry["mirror_url"], "spec": new_entry["spec"]} ) def update(self, with_cooldown=False): @@ -367,8 +361,7 @@ class BinaryCacheIndex(object): # May need to fetch the index and update the local caches try: needs_regen = self._fetch_and_cache_index( - cached_mirror_url, - cache_entry=cache_entry, + cached_mirror_url, cache_entry=cache_entry ) self._last_fetch_times[cached_mirror_url] = (now, True) all_methods_failed = False @@ -2006,12 +1999,7 @@ def try_direct_fetch(spec, mirrors=None): fetched_spec = Spec.from_json(specfile_contents) fetched_spec._mark_concrete() - found_specs.append( - { - "mirror_url": mirror.fetch_url, - "spec": fetched_spec, - } - ) + found_specs.append({"mirror_url": mirror.fetch_url, "spec": fetched_spec}) return found_specs @@ -2313,11 +2301,7 @@ def download_single_spec(concrete_spec, destination, mirror_url=None): local_tarball_path = os.path.join(destination, tarball_dir_name) files_to_fetch = [ - { - "url": [tarball_path_name], - "path": local_tarball_path, - "required": True, - }, + {"url": [tarball_path_name], "path": local_tarball_path, "required": True}, { "url": [ tarball_name(concrete_spec, ".spec.json.sig"), @@ -2438,12 +2422,7 @@ class DefaultIndexFetcher: response.headers.get("Etag", None) or response.headers.get("etag", None) ) - return FetchIndexResult( - etag=etag, - hash=computed_hash, - data=result, - fresh=False, - ) + return FetchIndexResult(etag=etag, hash=computed_hash, data=result, fresh=False) class EtagIndexFetcher: diff --git a/lib/spack/spack/bootstrap/__init__.py b/lib/spack/spack/bootstrap/__init__.py index 225e7d808e..1dad6597a6 100644 --- a/lib/spack/spack/bootstrap/__init__.py +++ b/lib/spack/spack/bootstrap/__init__.py @@ -5,11 +5,7 @@ """Function and classes needed to bootstrap Spack itself.""" from .config import ensure_bootstrap_configuration, is_bootstrapping -from .core import ( - all_core_root_specs, - ensure_core_dependencies, - ensure_patchelf_in_path_or_raise, -) +from .core import all_core_root_specs, ensure_core_dependencies, ensure_patchelf_in_path_or_raise from .environment import BootstrapEnvironment, ensure_environment_dependencies from .status import status_message diff --git a/lib/spack/spack/bootstrap/_common.py b/lib/spack/spack/bootstrap/_common.py index 31e6208ae6..3e464d1d86 100644 --- a/lib/spack/spack/bootstrap/_common.py +++ b/lib/spack/spack/bootstrap/_common.py @@ -59,10 +59,7 @@ def _try_import_from_store(module, query_spec, query_info=None): # to be picked up and used, possibly depending on something in the store, first # allows the bootstrap version to work when an incompatible version is in # sys.path - orders = [ - module_paths + sys.path, - sys.path + module_paths, - ] + orders = [module_paths + sys.path, sys.path + module_paths] for path in orders: sys.path = path try: diff --git a/lib/spack/spack/bootstrap/core.py b/lib/spack/spack/bootstrap/core.py index b9db0bad39..2021171a38 100644 --- a/lib/spack/spack/bootstrap/core.py +++ b/lib/spack/spack/bootstrap/core.py @@ -53,12 +53,7 @@ import spack.util.spack_yaml import spack.util.url import spack.version -from ._common import ( - _executables_in_store, - _python_import, - _root_spec, - _try_import_from_store, -) +from ._common import _executables_in_store, _python_import, _root_spec, _try_import_from_store from .config import spack_python_interpreter, spec_for_current_python #: Name of the file containing metadata about the bootstrapping source diff --git a/lib/spack/spack/bootstrap/environment.py b/lib/spack/spack/bootstrap/environment.py index 7eb8d3ad58..cc8d6c09b4 100644 --- a/lib/spack/spack/bootstrap/environment.py +++ b/lib/spack/spack/bootstrap/environment.py @@ -171,7 +171,7 @@ def mypy_root_spec(): def black_root_spec(): """Return the root spec used to bootstrap black""" - return _root_spec("py-black@:22.12.0") + return _root_spec("py-black@:23.1.0") def flake8_root_spec(): diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index b8ede1638a..1506233de9 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -1016,7 +1016,6 @@ def get_cmake_prefix_path(pkg): def _setup_pkg_and_run( serialized_pkg, function, kwargs, child_pipe, input_multiprocess_fd, jsfd1, jsfd2 ): - context = kwargs.get("context", "build") try: diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index fbe495ab68..a2594203ff 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -110,11 +110,7 @@ class AutotoolsBuilder(BaseBuilder): phases = ("autoreconf", "configure", "build", "install") #: Names associated with package methods in the old build-system format - legacy_methods = ( - "configure_args", - "check", - "installcheck", - ) + legacy_methods = ("configure_args", "check", "installcheck") #: Names associated with package attributes in the old build-system format legacy_attributes = ( diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index a98800a359..92b6a5122a 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -31,7 +31,6 @@ def cmake_cache_option(name, boolean_value, comment=""): class CachedCMakeBuilder(CMakeBuilder): - #: Phases of a Cached CMake package #: Note: the initconfig phase is used for developer builds as a final phase to stop on phases: Tuple[str, ...] = ("initconfig", "cmake", "build", "install") diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py index 06822c89a9..89a6c670d0 100644 --- a/lib/spack/spack/build_systems/cmake.py +++ b/lib/spack/spack/build_systems/cmake.py @@ -252,10 +252,7 @@ class CMakeBuilder(BaseBuilder): if platform.mac_ver()[0]: args.extend( - [ - define("CMAKE_FIND_FRAMEWORK", "LAST"), - define("CMAKE_FIND_APPBUNDLE", "LAST"), - ] + [define("CMAKE_FIND_FRAMEWORK", "LAST"), define("CMAKE_FIND_APPBUNDLE", "LAST")] ) # Set up CMake rpath diff --git a/lib/spack/spack/build_systems/generic.py b/lib/spack/spack/build_systems/generic.py index 1db40d9124..1e5759ae56 100644 --- a/lib/spack/spack/build_systems/generic.py +++ b/lib/spack/spack/build_systems/generic.py @@ -38,10 +38,7 @@ class GenericBuilder(BaseBuilder): legacy_methods: Tuple[str, ...] = () #: Names associated with package attributes in the old build-system format - legacy_attributes: Tuple[str, ...] = ( - "archive_files", - "install_time_test_callbacks", - ) + legacy_attributes: Tuple[str, ...] = ("archive_files", "install_time_test_callbacks") #: Callback names for post-install phase tests install_time_test_callbacks = [] diff --git a/lib/spack/spack/build_systems/intel.py b/lib/spack/spack/build_systems/intel.py index e9e9102043..771761119a 100644 --- a/lib/spack/spack/build_systems/intel.py +++ b/lib/spack/spack/build_systems/intel.py @@ -857,10 +857,7 @@ class IntelPackage(Package): raise_lib_error("Cannot find a BLACS library for the given MPI.") int_suff = "_" + self.intel64_int_suffix - scalapack_libnames = [ - "libmkl_scalapack" + int_suff, - blacs_lib + int_suff, - ] + scalapack_libnames = ["libmkl_scalapack" + int_suff, blacs_lib + int_suff] sca_libs = find_libraries( scalapack_libnames, root=self.component_lib_dir("mkl"), shared=("+shared" in self.spec) ) @@ -1161,9 +1158,7 @@ class IntelPackage(Package): # # Ideally, we just tell the installer to look around on the system. # Thankfully, we neither need to care nor emulate where it looks: - license_type = { - "ACTIVATION_TYPE": "exist_lic", - } + license_type = {"ACTIVATION_TYPE": "exist_lic"} # However (and only), if the spack-internal Intel license file has been # populated beyond its templated explanatory comments, proffer it to diff --git a/lib/spack/spack/build_systems/lua.py b/lib/spack/spack/build_systems/lua.py index 2eda67e513..ad67f50825 100644 --- a/lib/spack/spack/build_systems/lua.py +++ b/lib/spack/spack/build_systems/lua.py @@ -68,10 +68,7 @@ class LuaBuilder(spack.builder.Builder): @staticmethod def _generate_tree_line(name, prefix): - return """{{ name = "{name}", root = "{prefix}" }};""".format( - name=name, - prefix=prefix, - ) + return """{{ name = "{name}", root = "{prefix}" }};""".format(name=name, prefix=prefix) def generate_luarocks_config(self, pkg, spec, prefix): spec = self.pkg.spec diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py index 09611b1a3a..a6f96d45eb 100644 --- a/lib/spack/spack/build_systems/oneapi.py +++ b/lib/spack/spack/build_systems/oneapi.py @@ -37,11 +37,7 @@ class IntelOneApiPackage(Package): conflicts(c, msg="This package in only available for x86_64 and Linux") # Add variant to toggle environment modifications from vars.sh - variant( - "envmods", - default=True, - description="Toggles environment modifications", - ) + variant("envmods", default=True, description="Toggles environment modifications") @staticmethod def update_description(cls): diff --git a/lib/spack/spack/build_systems/sip.py b/lib/spack/spack/build_systems/sip.py index c7a345b245..c45254ebb0 100644 --- a/lib/spack/spack/build_systems/sip.py +++ b/lib/spack/spack/build_systems/sip.py @@ -61,10 +61,7 @@ class SIPPackage(spack.package_base.PackageBase): list: list of strings of module names """ modules = [] - root = os.path.join( - self.prefix, - self.spec["python"].package.platlib, - ) + root = os.path.join(self.prefix, self.spec["python"].package.platlib) # Some Python libraries are packages: collections of modules # distributed in directories containing __init__.py files diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py index 6ab6d12633..2eadb0929c 100644 --- a/lib/spack/spack/ci.py +++ b/lib/spack/spack/ci.py @@ -42,9 +42,7 @@ from spack.error import SpackError from spack.reporters import CDash, CDashConfiguration from spack.reporters.cdash import build_stamp as cdash_build_stamp -JOB_RETRY_CONDITIONS = [ - "always", -] +JOB_RETRY_CONDITIONS = ["always"] TEMP_STORAGE_MIRROR_NAME = "ci_temporary_mirror" SPACK_RESERVED_TAGS = ["public", "protected", "notary"] @@ -129,10 +127,7 @@ def _remove_reserved_tags(tags): def _get_spec_string(spec): - format_elements = [ - "{name}{@version}", - "{%compiler}", - ] + format_elements = ["{name}{@version}", "{%compiler}"] if spec.architecture: format_elements.append(" {arch=architecture}") @@ -328,12 +323,7 @@ def _compute_spec_deps(spec_list, check_index_only=False, mirrors_to_check=None) dependencies = [] def append_dep(s, d): - dependencies.append( - { - "spec": s, - "depends": d, - } - ) + dependencies.append({"spec": s, "depends": d}) for spec in spec_list: for s in spec.traverse(deptype=all): @@ -346,10 +336,7 @@ def _compute_spec_deps(spec_list, check_index_only=False, mirrors_to_check=None) ) skey = _spec_deps_key(s) - spec_labels[skey] = { - "spec": s, - "needs_rebuild": not up_to_date_mirrors, - } + spec_labels[skey] = {"spec": s, "needs_rebuild": not up_to_date_mirrors} for d in s.dependencies(deptype=all): dkey = _spec_deps_key(d) @@ -368,10 +355,7 @@ def _compute_spec_deps(spec_list, check_index_only=False, mirrors_to_check=None) } ) - deps_json_obj = { - "specs": specs, - "dependencies": dependencies, - } + deps_json_obj = {"specs": specs, "dependencies": dependencies} return deps_json_obj @@ -410,14 +394,7 @@ def _copy_attributes(attrs_list, src_dict, dest_dict): def _find_matching_config(spec, gitlab_ci): runner_attributes = {} - overridable_attrs = [ - "image", - "tags", - "variables", - "before_script", - "script", - "after_script", - ] + overridable_attrs = ["image", "tags", "variables", "before_script", "script", "after_script"] _copy_attributes(overridable_attrs, gitlab_ci, runner_attributes) @@ -685,28 +662,14 @@ def generate_gitlab_ci_yaml( except AttributeError: phase_name = phase strip_compilers = False - phases.append( - { - "name": phase_name, - "strip-compilers": strip_compilers, - } - ) + phases.append({"name": phase_name, "strip-compilers": strip_compilers}) for bs in env.spec_lists[phase_name]: bootstrap_specs.append( - { - "spec": bs, - "phase-name": phase_name, - "strip-compilers": strip_compilers, - } + {"spec": bs, "phase-name": phase_name, "strip-compilers": strip_compilers} ) - phases.append( - { - "name": "specs", - "strip-compilers": False, - } - ) + phases.append({"name": "specs", "strip-compilers": False}) # If a remote mirror override (alternate buildcache destination) was # specified, add it here in case it has already built hashes we might @@ -1109,15 +1072,9 @@ def generate_gitlab_ci_yaml( "variables": variables, "script": job_script, "tags": tags, - "artifacts": { - "paths": artifact_paths, - "when": "always", - }, + "artifacts": {"paths": artifact_paths, "when": "always"}, "needs": sorted(job_dependencies, key=lambda d: d["job"]), - "retry": { - "max": 2, - "when": JOB_RETRY_CONDITIONS, - }, + "retry": {"max": 2, "when": JOB_RETRY_CONDITIONS}, "interruptible": True, } @@ -1135,10 +1092,7 @@ def generate_gitlab_ci_yaml( if image_name: job_object["image"] = image_name if image_entry is not None: - job_object["image"] = { - "name": image_name, - "entrypoint": image_entry, - } + job_object["image"] = {"name": image_name, "entrypoint": image_entry} output_object[job_name] = job_object job_id += 1 @@ -1181,11 +1135,7 @@ def generate_gitlab_ci_yaml( service_job_retries = { "max": 2, - "when": [ - "runner_system_failure", - "stuck_or_timeout_failure", - "script_failure", - ], + "when": ["runner_system_failure", "stuck_or_timeout_failure", "script_failure"], } if job_id > 0: @@ -1357,9 +1307,7 @@ def generate_gitlab_ci_yaml( _copy_attributes(default_attrs, service_job_config, noop_job) if "script" not in noop_job: - noop_job["script"] = [ - 'echo "All specs already up to date, nothing to rebuild."', - ] + noop_job["script"] = ['echo "All specs already up to date, nothing to rebuild."'] noop_job["retry"] = service_job_retries @@ -1620,9 +1568,7 @@ def download_and_extract_artifacts(url, work_dir): """ tty.msg("Fetching artifacts from: {0}\n".format(url)) - headers = { - "Content-Type": "application/zip", - } + headers = {"Content-Type": "application/zip"} token = os.environ.get("GITLAB_PRIVATE_TOKEN", None) if token: @@ -2081,10 +2027,7 @@ def write_broken_spec(url, pkg_name, stack_name, job_url, pipeline_url, spec_dic with open(file_path, "w") as fd: fd.write(syaml.dump(broken_spec_details)) web_util.push_to_url( - file_path, - url, - keep_original=False, - extra_args={"ContentType": "text/plain"}, + file_path, url, keep_original=False, extra_args={"ContentType": "text/plain"} ) except Exception as err: # If there is an S3 error (e.g., access denied or connection @@ -2162,14 +2105,7 @@ def run_standalone_tests(**kwargs): tty.error("Reproduction directory is required for stand-alone tests") return - test_args = [ - "spack", - "--color=always", - "--backtrace", - "--verbose", - "test", - "run", - ] + test_args = ["spack", "--color=always", "--backtrace", "--verbose", "test", "run"] if fail_fast: test_args.append("--fail-fast") @@ -2319,19 +2255,9 @@ class CDashHandler(object): opener = build_opener(HTTPHandler) - parent_group_id = self.create_buildgroup( - opener, - headers, - url, - self.build_group, - "Daily", - ) + parent_group_id = self.create_buildgroup(opener, headers, url, self.build_group, "Daily") group_id = self.create_buildgroup( - opener, - headers, - url, - "Latest {0}".format(self.build_group), - "Latest", + opener, headers, url, "Latest {0}".format(self.build_group), "Latest" ) if not parent_group_id or not group_id: @@ -2341,13 +2267,9 @@ class CDashHandler(object): data = { "dynamiclist": [ - { - "match": name, - "parentgroupid": parent_group_id, - "site": self.site, - } + {"match": name, "parentgroupid": parent_group_id, "site": self.site} for name in job_names - ], + ] } enc_data = json.dumps(data).encode("utf-8") diff --git a/lib/spack/spack/ci_optimization.py b/lib/spack/spack/ci_optimization.py index 7b2128e255..bb9e5eec16 100644 --- a/lib/spack/spack/ci_optimization.py +++ b/lib/spack/spack/ci_optimization.py @@ -43,7 +43,6 @@ def matches(obj, proto): return all((key in obj and matches(obj[key], val)) for key, val in proto.items()) if isinstance(obj, collections.abc.Sequence) and not isinstance(obj, str): - if not (isinstance(proto, collections.abc.Sequence) and not isinstance(proto, str)): return False diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py index b3251cef55..f0dbc4d43e 100644 --- a/lib/spack/spack/cmd/__init__.py +++ b/lib/spack/spack/cmd/__init__.py @@ -161,9 +161,7 @@ class _UnquotedFlags(object): """ flags_arg_pattern = re.compile( - r'^({0})=([^\'"].*)$'.format( - "|".join(spack.spec.FlagMap.valid_compiler_flags()), - ) + r'^({0})=([^\'"].*)$'.format("|".join(spack.spec.FlagMap.valid_compiler_flags())) ) def __init__(self, all_unquoted_flag_pairs: List[Tuple[Match[str], str]]): @@ -227,7 +225,6 @@ def parse_specs(args, **kwargs): return specs except spack.error.SpecError as e: - msg = e.message if e.long_message: msg += e.long_message diff --git a/lib/spack/spack/cmd/audit.py b/lib/spack/spack/cmd/audit.py index 9706f995c6..cb71dbbcb2 100644 --- a/lib/spack/spack/cmd/audit.py +++ b/lib/spack/spack/cmd/audit.py @@ -53,7 +53,6 @@ def packages(parser, args): def packages_https(parser, args): - # Since packages takes a long time, --all is required without name if not args.check_all and not args.name: tty.die("Please specify one or more packages to audit, or --all.") diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py index b1be9b6056..7532271054 100644 --- a/lib/spack/spack/cmd/buildcache.py +++ b/lib/spack/spack/cmd/buildcache.py @@ -103,9 +103,7 @@ def setup_parser(subparser): help="Regenerate buildcache index after building package(s)", ) create.add_argument( - "--spec-file", - default=None, - help="Create buildcache entry for spec from json or yaml file", + "--spec-file", default=None, help="Create buildcache entry for spec from json or yaml file" ) create.add_argument( "--only", diff --git a/lib/spack/spack/cmd/change.py b/lib/spack/spack/cmd/change.py index 652d42db14..0a57cb6da5 100644 --- a/lib/spack/spack/cmd/change.py +++ b/lib/spack/spack/cmd/change.py @@ -20,9 +20,7 @@ def setup_parser(subparser): help="name of the list to remove specs from", ) subparser.add_argument( - "--match-spec", - dest="match_spec", - help="if name is ambiguous, supply a spec to match", + "--match-spec", dest="match_spec", help="if name is ambiguous, supply a spec to match" ) subparser.add_argument( "-a", diff --git a/lib/spack/spack/cmd/ci.py b/lib/spack/spack/cmd/ci.py index aadc47fc2c..1127399842 100644 --- a/lib/spack/spack/cmd/ci.py +++ b/lib/spack/spack/cmd/ci.py @@ -548,13 +548,7 @@ def ci_rebuild(args): commands = [ # apparently there's a race when spack bootstraps? do it up front once - [ - SPACK_COMMAND, - "-e", - env.path, - "bootstrap", - "now", - ], + [SPACK_COMMAND, "-e", env.path, "bootstrap", "now"], [ SPACK_COMMAND, "-e", diff --git a/lib/spack/spack/cmd/commands.py b/lib/spack/spack/cmd/commands.py index 14703bf8a5..d26d67bc32 100644 --- a/lib/spack/spack/cmd/commands.py +++ b/lib/spack/spack/cmd/commands.py @@ -13,11 +13,7 @@ import sys import llnl.util.filesystem as fs import llnl.util.tty as tty -from llnl.util.argparsewriter import ( - ArgparseCompletionWriter, - ArgparseRstWriter, - ArgparseWriter, -) +from llnl.util.argparsewriter import ArgparseCompletionWriter, ArgparseRstWriter, ArgparseWriter from llnl.util.tty.colify import colify import spack.cmd @@ -42,7 +38,7 @@ update_completion_args = { "format": "bash", "header": os.path.join(spack.paths.share_path, "bash", "spack-completion.in"), "update": os.path.join(spack.paths.share_path, "spack-completion.bash"), - }, + } } diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py index 9ccf6f9e9b..0ab66d449f 100644 --- a/lib/spack/spack/cmd/config.py +++ b/lib/spack/spack/cmd/config.py @@ -408,13 +408,7 @@ def config_prefer_upstream(args): pkgs = {} for spec in pref_specs: # Collect all the upstream compilers and versions for this package. - pkg = pkgs.get( - spec.name, - { - "version": [], - "compiler": [], - }, - ) + pkg = pkgs.get(spec.name, {"version": [], "compiler": []}) pkgs[spec.name] = pkg # We have no existing variant if this is our first added version. diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py index bf796e47dc..8ee259c52d 100644 --- a/lib/spack/spack/cmd/create.py +++ b/lib/spack/spack/cmd/create.py @@ -16,19 +16,10 @@ import spack.repo import spack.stage import spack.util.web from spack.spec import Spec -from spack.url import ( - UndetectableNameError, - UndetectableVersionError, - parse_name, - parse_version, -) +from spack.url import UndetectableNameError, UndetectableVersionError, parse_name, parse_version from spack.util.editor import editor from spack.util.executable import ProcessError, which -from spack.util.naming import ( - mod_to_class, - simplify_name, - valid_fully_qualified_module_name, -) +from spack.util.naming import mod_to_class, simplify_name, valid_fully_qualified_module_name description = "create a new package file" section = "packaging" diff --git a/lib/spack/spack/cmd/debug.py b/lib/spack/spack/cmd/debug.py index 3b8c151294..8c3cb93d17 100644 --- a/lib/spack/spack/cmd/debug.py +++ b/lib/spack/spack/cmd/debug.py @@ -96,8 +96,5 @@ def report(args): def debug(parser, args): - action = { - "create-db-tarball": create_db_tarball, - "report": report, - } + action = {"create-db-tarball": create_db_tarball, "report": report} action[args.debug_command](args) diff --git a/lib/spack/spack/cmd/deprecate.py b/lib/spack/spack/cmd/deprecate.py index 47215ed131..3f0994f564 100644 --- a/lib/spack/spack/cmd/deprecate.py +++ b/lib/spack/spack/cmd/deprecate.py @@ -33,12 +33,7 @@ section = "admin" level = "long" # Arguments for display_specs when we find ambiguity -display_args = { - "long": True, - "show_flags": True, - "variants": True, - "indent": 4, -} +display_args = {"long": True, "show_flags": True, "variants": True, "indent": 4} def setup_parser(sp): diff --git a/lib/spack/spack/cmd/diff.py b/lib/spack/spack/cmd/diff.py index 5206a246c0..13c27aec2c 100644 --- a/lib/spack/spack/cmd/diff.py +++ b/lib/spack/spack/cmd/diff.py @@ -80,22 +80,12 @@ def compare_specs(a, b, to_string=False, color=None): # specs and to descend into dependency hashes so we include all facts. a_facts = set( shift(func) - for func in setup.spec_clauses( - a, - body=True, - expand_hashes=True, - concrete_build_deps=True, - ) + for func in setup.spec_clauses(a, body=True, expand_hashes=True, concrete_build_deps=True) if func.name == "attr" ) b_facts = set( shift(func) - for func in setup.spec_clauses( - b, - body=True, - expand_hashes=True, - concrete_build_deps=True, - ) + for func in setup.spec_clauses(b, body=True, expand_hashes=True, concrete_build_deps=True) if func.name == "attr" ) diff --git a/lib/spack/spack/cmd/env.py b/lib/spack/spack/cmd/env.py index fd8bf2de56..fe7d1ad59a 100644 --- a/lib/spack/spack/cmd/env.py +++ b/lib/spack/spack/cmd/env.py @@ -148,8 +148,7 @@ def env_activate(args): if not args.shell: spack.cmd.common.shell_init_instructions( - "spack env activate", - " eval `spack env activate {sh_arg} [...]`", + "spack env activate", " eval `spack env activate {sh_arg} [...]`" ) return 1 @@ -238,8 +237,7 @@ def env_deactivate_setup_parser(subparser): def env_deactivate(args): if not args.shell: spack.cmd.common.shell_init_instructions( - "spack env deactivate", - " eval `spack env deactivate {sh_arg}`", + "spack env deactivate", " eval `spack env deactivate {sh_arg}`" ) return 1 diff --git a/lib/spack/spack/cmd/external.py b/lib/spack/spack/cmd/external.py index 51e468e1bc..d859ad9d7a 100644 --- a/lib/spack/spack/cmd/external.py +++ b/lib/spack/spack/cmd/external.py @@ -38,11 +38,7 @@ def setup_parser(subparser): default=False, help="packages with detected externals won't be built with Spack", ) - find_parser.add_argument( - "--exclude", - action="append", - help="packages to exclude from search", - ) + find_parser.add_argument("--exclude", action="append", help="packages to exclude from search") find_parser.add_argument( "-p", "--path", @@ -187,7 +183,6 @@ def external_read_cray_manifest(args): def _collect_and_consume_cray_manifest_files( manifest_file=None, manifest_directory=None, dry_run=False, fail_on_error=False ): - manifest_files = [] if manifest_file: manifest_files.append(manifest_file) diff --git a/lib/spack/spack/cmd/fetch.py b/lib/spack/spack/cmd/fetch.py index 0bfd513070..663c57c4cb 100644 --- a/lib/spack/spack/cmd/fetch.py +++ b/lib/spack/spack/cmd/fetch.py @@ -25,10 +25,7 @@ def setup_parser(subparser): help="fetch only missing (not yet installed) dependencies", ) subparser.add_argument( - "-D", - "--dependencies", - action="store_true", - help="also fetch all dependencies", + "-D", "--dependencies", action="store_true", help="also fetch all dependencies" ) arguments.add_common_arguments(subparser, ["specs"]) subparser.epilog = ( diff --git a/lib/spack/spack/cmd/graph.py b/lib/spack/spack/cmd/graph.py index 5a953f9ae5..a0fd16f19f 100644 --- a/lib/spack/spack/cmd/graph.py +++ b/lib/spack/spack/cmd/graph.py @@ -9,13 +9,7 @@ import spack.cmd.common.arguments as arguments import spack.config import spack.environment as ev import spack.store -from spack.graph import ( - DAGWithDependencyTypes, - SimpleDAG, - graph_ascii, - graph_dot, - static_graph_dot, -) +from spack.graph import DAGWithDependencyTypes, SimpleDAG, graph_ascii, graph_dot, static_graph_dot description = "generate graphs of package dependency relationships" section = "basic" diff --git a/lib/spack/spack/cmd/help.py b/lib/spack/spack/cmd/help.py index f719195e91..1f45735158 100644 --- a/lib/spack/spack/cmd/help.py +++ b/lib/spack/spack/cmd/help.py @@ -87,9 +87,7 @@ spec expression syntax: """ -guides = { - "spec": spec_guide, -} +guides = {"spec": spec_guide} def setup_parser(subparser): diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 81cfebc19e..51f18479ee 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -496,9 +496,7 @@ def install(parser, args): return None context_manager = spack.report.build_context_manager( - reporter=args.reporter(), - filename=report_filename(args, specs=specs), - specs=specs, + reporter=args.reporter(), filename=report_filename(args, specs=specs), specs=specs ) return context_manager diff --git a/lib/spack/spack/cmd/license.py b/lib/spack/spack/cmd/license.py index 27facdcaee..454fefcece 100644 --- a/lib/spack/spack/cmd/license.py +++ b/lib/spack/spack/cmd/license.py @@ -58,10 +58,7 @@ licensed_files = [ #: licensed files that can have LGPL language in them #: so far, just this command -- so it can find LGPL things elsewhere -lgpl_exceptions = [ - r"lib/spack/spack/cmd/license.py", - r"lib/spack/spack/test/cmd/license.py", -] +lgpl_exceptions = [r"lib/spack/spack/cmd/license.py", r"lib/spack/spack/test/cmd/license.py"] def _all_spack_files(root=spack.paths.prefix): @@ -129,7 +126,6 @@ class LicenseError(object): def _check_license(lines, path): - found = [] for line in lines: diff --git a/lib/spack/spack/cmd/load.py b/lib/spack/spack/cmd/load.py index 4f60ab3d52..ee9ee939e8 100644 --- a/lib/spack/spack/cmd/load.py +++ b/lib/spack/spack/cmd/load.py @@ -98,8 +98,7 @@ def load(parser, args): if not args.shell: specs_str = " ".join(args.constraint) or "SPECS" spack.cmd.common.shell_init_instructions( - "spack load", - " eval `spack load {sh_arg} %s`" % specs_str, + "spack load", " eval `spack load {sh_arg} %s`" % specs_str ) return 1 diff --git a/lib/spack/spack/cmd/mark.py b/lib/spack/spack/cmd/mark.py index d7a3c06642..1d125cc409 100644 --- a/lib/spack/spack/cmd/mark.py +++ b/lib/spack/spack/cmd/mark.py @@ -27,12 +27,7 @@ error_message = """You can either: """ # Arguments for display_specs when we find ambiguity -display_args = { - "long": True, - "show_flags": False, - "variants": False, - "indent": 4, -} +display_args = {"long": True, "show_flags": False, "variants": False, "indent": 4} def setup_parser(subparser): diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py index 21319d9fdf..8ad10b1a6c 100644 --- a/lib/spack/spack/cmd/mirror.py +++ b/lib/spack/spack/cmd/mirror.py @@ -445,9 +445,7 @@ def mirror_create(args): mirror_specs = concrete_specs_from_user(args) create_mirror_for_individual_specs( - mirror_specs, - path=path, - skip_unstable_versions=args.skip_unstable_versions, + mirror_specs, path=path, skip_unstable_versions=args.skip_unstable_versions ) @@ -467,9 +465,7 @@ def create_mirror_for_all_specs(path, skip_unstable_versions, selection_fn): def create_mirror_for_all_specs_inside_environment(path, skip_unstable_versions, selection_fn): mirror_specs = concrete_specs_from_environment(selection_fn=selection_fn) create_mirror_for_individual_specs( - mirror_specs, - path=path, - skip_unstable_versions=skip_unstable_versions, + mirror_specs, path=path, skip_unstable_versions=skip_unstable_versions ) diff --git a/lib/spack/spack/cmd/modules/__init__.py b/lib/spack/spack/cmd/modules/__init__.py index c3bb74c096..107189f814 100644 --- a/lib/spack/spack/cmd/modules/__init__.py +++ b/lib/spack/spack/cmd/modules/__init__.py @@ -180,10 +180,7 @@ def loads(module_type, specs, args, out=None): for spec in specs ) - module_commands = { - "tcl": "module load ", - "lmod": "module load ", - } + module_commands = {"tcl": "module load ", "lmod": "module load "} d = {"command": "" if not args.shell else module_commands[module_type], "prefix": args.prefix} @@ -368,18 +365,14 @@ callbacks = {"refresh": refresh, "rm": rm, "find": find, "loads": loads} def modules_cmd(parser, args, module_type, callbacks=callbacks): - # Qualifiers to be used when querying the db for specs - constraint_qualifiers = { - "refresh": {"installed": True, "known": True}, - } + constraint_qualifiers = {"refresh": {"installed": True, "known": True}} query_args = constraint_qualifiers.get(args.subparser_name, {}) # Get the specs that match the query from the DB specs = args.specs(**query_args) try: - callbacks[args.subparser_name](module_type, specs, args) except MultipleSpecsMatch: diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py index 69caeb421f..3752c16f41 100644 --- a/lib/spack/spack/cmd/solve.py +++ b/lib/spack/spack/cmd/solve.py @@ -182,11 +182,7 @@ def solve(parser, args): # set up solver parameters # Note: reuse and other concretizer prefs are passed as configuration result = solver.solve( - specs, - out=output, - timers=args.timers, - stats=args.stats, - setup_only=setup_only, + specs, out=output, timers=args.timers, stats=args.stats, setup_only=setup_only ) if not setup_only: _process_result(result, show, required_format, kwargs) diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py index 9ff19dcff8..b31c7a93b7 100644 --- a/lib/spack/spack/cmd/spec.py +++ b/lib/spack/spack/cmd/spec.py @@ -110,7 +110,7 @@ def spec(parser, args): else: tty.die("spack spec requires at least one spec or an active environment") - for (input, output) in specs: + for input, output in specs: # With -y, just print YAML to output. if args.format: if args.format == "yaml": diff --git a/lib/spack/spack/cmd/style.py b/lib/spack/spack/cmd/style.py index ff9e5af6b5..a75171379f 100644 --- a/lib/spack/spack/cmd/style.py +++ b/lib/spack/spack/cmd/style.py @@ -30,20 +30,13 @@ def grouper(iterable, n, fillvalue=None): #: List of directories to exclude from checks -- relative to spack root -exclude_directories = [ - os.path.relpath(spack.paths.external_path, spack.paths.prefix), -] +exclude_directories = [os.path.relpath(spack.paths.external_path, spack.paths.prefix)] #: Order in which tools should be run. flake8 is last so that it can #: double-check the results of other tools (if, e.g., --fix was provided) #: The list maps an executable name to a method to ensure the tool is #: bootstrapped or present in the environment. -tool_names = [ - "isort", - "black", - "flake8", - "mypy", -] +tool_names = ["isort", "black", "flake8", "mypy"] #: tools we run in spack style tools = {} @@ -52,7 +45,7 @@ tools = {} mypy_ignores = [ # same as `disable_error_code = "annotation-unchecked"` in pyproject.toml, which # doesn't exist in mypy 0.971 for Python 3.6 - "[annotation-unchecked]", + "[annotation-unchecked]" ] @@ -150,10 +143,7 @@ def setup_parser(subparser): help="branch to compare against to determine changed files (default: develop)", ) subparser.add_argument( - "-a", - "--all", - action="store_true", - help="check all files, not just changed files", + "-a", "--all", action="store_true", help="check all files, not just changed files" ) subparser.add_argument( "-r", @@ -178,10 +168,7 @@ def setup_parser(subparser): help="format automatically if possible (e.g., with isort, black)", ) subparser.add_argument( - "--root", - action="store", - default=None, - help="style check a different spack instance", + "--root", action="store", default=None, help="style check a different spack instance" ) tool_group = subparser.add_mutually_exclusive_group() @@ -211,6 +198,7 @@ def rewrite_and_print_output( output, args, re_obj=re.compile(r"^(.+):([0-9]+):"), replacement=r"{0}:{1}:" ): """rewrite ouput with <file>:<line>: format to respect path args""" + # print results relative to current working directory def translate(match): return replacement.format(cwd_relative(match.group(1), args), *list(match.groups()[1:])) @@ -281,24 +269,10 @@ def run_mypy(mypy_cmd, file_list, args): os.path.join(spack.paths.prefix, "pyproject.toml"), "--show-error-codes", ] - mypy_arg_sets = [ - common_mypy_args - + [ - "--package", - "spack", - "--package", - "llnl", - ] - ] + mypy_arg_sets = [common_mypy_args + ["--package", "spack", "--package", "llnl"]] if "SPACK_MYPY_CHECK_PACKAGES" in os.environ: mypy_arg_sets.append( - common_mypy_args - + [ - "--package", - "packages", - "--disable-error-code", - "no-redef", - ] + common_mypy_args + ["--package", "packages", "--disable-error-code", "no-redef"] ) returncode = 0 diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py index 7c917207c4..0baab069eb 100644 --- a/lib/spack/spack/cmd/test.py +++ b/lib/spack/spack/cmd/test.py @@ -33,9 +33,7 @@ def setup_parser(subparser): # Run run_parser = sp.add_parser( - "run", - description=test_run.__doc__, - help=spack.cmd.first_line(test_run.__doc__), + "run", description=test_run.__doc__, help=spack.cmd.first_line(test_run.__doc__) ) alias_help_msg = "Provide an alias for this test-suite" @@ -80,9 +78,7 @@ def setup_parser(subparser): # List list_parser = sp.add_parser( - "list", - description=test_list.__doc__, - help=spack.cmd.first_line(test_list.__doc__), + "list", description=test_list.__doc__, help=spack.cmd.first_line(test_list.__doc__) ) list_parser.add_argument( "-a", @@ -96,9 +92,7 @@ def setup_parser(subparser): # Find find_parser = sp.add_parser( - "find", - description=test_find.__doc__, - help=spack.cmd.first_line(test_find.__doc__), + "find", description=test_find.__doc__, help=spack.cmd.first_line(test_find.__doc__) ) find_parser.add_argument( "filter", @@ -108,9 +102,7 @@ def setup_parser(subparser): # Status status_parser = sp.add_parser( - "status", - description=test_status.__doc__, - help=spack.cmd.first_line(test_status.__doc__), + "status", description=test_status.__doc__, help=spack.cmd.first_line(test_status.__doc__) ) status_parser.add_argument( "names", nargs=argparse.REMAINDER, help="Test suites for which to print status" @@ -147,9 +139,7 @@ def setup_parser(subparser): # Remove remove_parser = sp.add_parser( - "remove", - description=test_remove.__doc__, - help=spack.cmd.first_line(test_remove.__doc__), + "remove", description=test_remove.__doc__, help=spack.cmd.first_line(test_remove.__doc__) ) arguments.add_common_arguments(remove_parser, ["yes_to_all"]) remove_parser.add_argument( @@ -189,11 +179,7 @@ def test_run(args): specs = spack.cmd.parse_specs(args.specs) if args.specs else [None] specs_to_test = [] for spec in specs: - matching = spack.store.db.query_local( - spec, - hashes=hashes, - explicit=explicit, - ) + matching = spack.store.db.query_local(spec, hashes=hashes, explicit=explicit) if spec and not matching: tty.warn("No {0}installed packages match spec {1}".format(explicit_str, spec)) """ diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py index 869ab88f62..888ba15f56 100644 --- a/lib/spack/spack/cmd/uninstall.py +++ b/lib/spack/spack/cmd/uninstall.py @@ -31,12 +31,7 @@ error_message = """You can either: """ # Arguments for display_specs when we find ambiguity -display_args = { - "long": True, - "show_flags": False, - "variants": False, - "indent": 4, -} +display_args = {"long": True, "show_flags": False, "variants": False, "indent": 4} def setup_parser(subparser): @@ -236,12 +231,7 @@ def do_uninstall(specs, force=False): hashes_to_remove = set(s.dag_hash() for s in specs) for s in traverse.traverse_nodes( - specs, - order="topo", - direction="children", - root=True, - cover="nodes", - deptype="all", + specs, order="topo", direction="children", root=True, cover="nodes", deptype="all" ): if s.dag_hash() in hashes_to_remove: spack.package_base.PackageBase.uninstall_by_spec(s, force=force) diff --git a/lib/spack/spack/cmd/unload.py b/lib/spack/spack/cmd/unload.py index 1867ff64e7..9b076ffd66 100644 --- a/lib/spack/spack/cmd/unload.py +++ b/lib/spack/spack/cmd/unload.py @@ -77,8 +77,7 @@ def unload(parser, args): specs_str = " ".join(args.specs) or "SPECS" spack.cmd.common.shell_init_instructions( - "spack unload", - " eval `spack unload {sh_arg}` %s" % specs_str, + "spack unload", " eval `spack unload {sh_arg}` %s" % specs_str ) return 1 diff --git a/lib/spack/spack/cmd/url.py b/lib/spack/spack/cmd/url.py index d93d2cc458..86ffde231d 100644 --- a/lib/spack/spack/cmd/url.py +++ b/lib/spack/spack/cmd/url.py @@ -106,12 +106,7 @@ def setup_parser(subparser): def url(parser, args): - action = { - "parse": url_parse, - "list": url_list, - "summary": url_summary, - "stats": url_stats, - } + action = {"parse": url_parse, "list": url_list, "summary": url_summary, "stats": url_stats} action[args.subcommand](args) diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 4b304096b1..9b48ee847c 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -619,11 +619,9 @@ def arguments_to_detect_version_fn(operating_system, paths): command_arguments = [] files_to_be_tested = fs.files_in(*search_paths) for compiler_name in spack.compilers.supported_compilers(): - compiler_cls = class_for_compiler_name(compiler_name) for language in ("cc", "cxx", "f77", "fc"): - # Select only the files matching a regexp for (file, full_path), regexp in itertools.product( files_to_be_tested, compiler_cls.search_regexps(language) diff --git a/lib/spack/spack/compilers/apple_clang.py b/lib/spack/spack/compilers/apple_clang.py index 57e7d01519..e4bef2c4bb 100644 --- a/lib/spack/spack/compilers/apple_clang.py +++ b/lib/spack/spack/compilers/apple_clang.py @@ -154,10 +154,7 @@ class AppleClang(spack.compilers.clang.Clang): ), ) - real_dirs = [ - "Toolchains/XcodeDefault.xctoolchain/usr/bin", - "usr/bin", - ] + real_dirs = ["Toolchains/XcodeDefault.xctoolchain/usr/bin", "usr/bin"] bins = ["c++", "c89", "c99", "cc", "clang", "clang++", "cpp"] diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 07a6275a12..1cb060a8b5 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -793,7 +793,7 @@ def _config(): configuration_paths = [ # Default configuration scope is the lowest-level scope. These are # versioned with Spack and can be overridden by systems, sites or users - configuration_defaults_path, + configuration_defaults_path ] disable_local_config = "SPACK_DISABLE_LOCAL_CONFIG" in os.environ @@ -801,15 +801,11 @@ def _config(): # System configuration is per machine. # This is disabled if user asks for no local configuration. if not disable_local_config: - configuration_paths.append( - ("system", spack.paths.system_config_path), - ) + configuration_paths.append(("system", spack.paths.system_config_path)) # Site configuration is per spack instance, for sites or projects # No site-level configs should be checked into spack by default. - configuration_paths.append( - ("site", os.path.join(spack.paths.etc_path)), - ) + configuration_paths.append(("site", os.path.join(spack.paths.etc_path))) # User configuration can override both spack defaults and site config # This is disabled if user asks for no local configuration. diff --git a/lib/spack/spack/cray_manifest.py b/lib/spack/spack/cray_manifest.py index c2908f61be..6f686aaf57 100644 --- a/lib/spack/spack/cray_manifest.py +++ b/lib/spack/spack/cray_manifest.py @@ -18,10 +18,7 @@ from spack.schema.cray_manifest import schema as manifest_schema #: packages here. default_path = "/opt/cray/pe/cpe-descriptive-manifest/" -compiler_name_translation = { - "nvidia": "nvhpc", - "rocm": "rocmcc", -} +compiler_name_translation = {"nvidia": "nvhpc", "rocm": "rocmcc"} def translated_compiler_name(manifest_compiler_name): diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py index 0607c6312a..2e012a67d5 100644 --- a/lib/spack/spack/database.py +++ b/lib/spack/spack/database.py @@ -46,10 +46,7 @@ import spack.spec import spack.store import spack.util.lock as lk import spack.util.spack_json as sjson -from spack.directory_layout import ( - DirectoryLayoutError, - InconsistentInstallDirectoryError, -) +from spack.directory_layout import DirectoryLayoutError, InconsistentInstallDirectoryError from spack.error import SpackError from spack.util.crypto import bit_length from spack.version import Version @@ -108,10 +105,7 @@ default_install_record_fields = [ def reader(version): - reader_cls = { - Version("5"): spack.spec.SpecfileV1, - Version("6"): spack.spec.SpecfileV3, - } + reader_cls = {Version("5"): spack.spec.SpecfileV1, Version("6"): spack.spec.SpecfileV3} return reader_cls[version] diff --git a/lib/spack/spack/detection/common.py b/lib/spack/spack/detection/common.py index e809f5f5ec..7e1e5e6a41 100644 --- a/lib/spack/spack/detection/common.py +++ b/lib/spack/spack/detection/common.py @@ -377,7 +377,8 @@ def compute_windows_user_path_for_package(pkg): install location, return list of potential locations based on common heuristics. For more info on Windows user specific installs see: - https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.8""" + https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.8 + """ if not is_windows: return [] diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index c008cc5c7e..a46b8f9835 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -45,11 +45,7 @@ import spack.util.path import spack.util.spack_json as sjson import spack.util.spack_yaml as syaml import spack.util.url -from spack.filesystem_view import ( - SimpleFilesystemView, - inverse_view_func_parser, - view_func_parser, -) +from spack.filesystem_view import SimpleFilesystemView, inverse_view_func_parser, view_func_parser from spack.installer import PackageInstaller from spack.spec import Spec from spack.spec_list import InvalidSpecConstraintError, SpecList @@ -304,12 +300,7 @@ def _write_yaml(data, str_or_file): def _eval_conditional(string): """Evaluate conditional definitions using restricted variable scope.""" valid_variables = spack.util.environment.get_host_environment() - valid_variables.update( - { - "re": re, - "env": os.environ, - } - ) + valid_variables.update({"re": re, "env": os.environ}) return eval(string, valid_variables) @@ -973,9 +964,7 @@ class Environment(object): config_path = os.path.join(config_path, basename) else: staged_path = spack.config.fetch_remote_configs( - config_path, - self.config_stage_dir, - skip_existing=True, + config_path, self.config_stage_dir, skip_existing=True ) if not staged_path: raise SpackEnvironmentError( diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index 720a28b9bd..19ad454ec5 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -35,13 +35,7 @@ from typing import List, Optional import llnl.util import llnl.util.filesystem as fs import llnl.util.tty as tty -from llnl.util.filesystem import ( - get_single_file, - mkdirp, - temp_cwd, - temp_rename, - working_dir, -) +from llnl.util.filesystem import get_single_file, mkdirp, temp_cwd, temp_rename, working_dir from llnl.util.symlink import symlink import spack.config @@ -1555,11 +1549,7 @@ def for_package_version(pkg, version): # performance hit for branches on older versions of git. # Branches cannot be cached, so we tell the fetcher not to cache tags/branches ref_type = "commit" if version.is_commit else "tag" - kwargs = { - "git": pkg.git, - ref_type: version.ref, - "no_cache": True, - } + kwargs = {"git": pkg.git, ref_type: version.ref, "no_cache": True} kwargs["submodules"] = getattr(pkg, "submodules", False) diff --git a/lib/spack/spack/hooks/absolutify_elf_sonames.py b/lib/spack/spack/hooks/absolutify_elf_sonames.py index 149708f9a3..91377706e3 100644 --- a/lib/spack/spack/hooks/absolutify_elf_sonames.py +++ b/lib/spack/spack/hooks/absolutify_elf_sonames.py @@ -37,7 +37,6 @@ class SharedLibrariesVisitor(BaseDirectoryVisitor): exception of an exclude list.""" def __init__(self, exclude_list): - # List of file and directory names to be excluded self.exclude_list = frozenset(exclude_list) diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py index fcea77d829..e62d2bfa40 100644 --- a/lib/spack/spack/hooks/sbang.py +++ b/lib/spack/spack/hooks/sbang.py @@ -212,8 +212,7 @@ def install_sbang(): # copy over the fresh copy of `sbang` sbang_tmp_path = os.path.join( - os.path.dirname(sbang_path), - ".%s.tmp" % os.path.basename(sbang_path), + os.path.dirname(sbang_path), ".%s.tmp" % os.path.basename(sbang_path) ) shutil.copy(spack.paths.sbang_script, sbang_tmp_path) diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py index 1b9800054d..7bbe8b2dd2 100644 --- a/lib/spack/spack/installer.py +++ b/lib/spack/spack/installer.py @@ -423,11 +423,7 @@ def _try_install_from_binary_cache(pkg, explicit, unsigned=False, timer=timer.NU matches = binary_distribution.get_mirrors_for_spec(pkg.spec, index_only=True) return _process_binary_cache_tarball( - pkg, - explicit, - unsigned, - mirrors_for_spec=matches, - timer=timer, + pkg, explicit, unsigned, mirrors_for_spec=matches, timer=timer ) @@ -789,7 +785,7 @@ class PackageInstaller(object): associated dependents """ packages = _packages_needed_to_bootstrap_compiler(compiler, architecture, pkgs) - for (comp_pkg, is_compiler) in packages: + for comp_pkg, is_compiler in packages: pkgid = package_id(comp_pkg) if pkgid not in self.build_tasks: self._add_init_task(comp_pkg, request, is_compiler, all_deps) @@ -813,8 +809,7 @@ class PackageInstaller(object): key, task = tup if task.pkg_id == pkgid: tty.debug( - "Modifying task for {0} to treat it as a compiler".format(pkgid), - level=2, + "Modifying task for {0} to treat it as a compiler".format(pkgid), level=2 ) setattr(task, attr, value) self.build_pq[i] = (key, task) @@ -1212,7 +1207,6 @@ class PackageInstaller(object): install_package = request.install_args.get("install_package") if install_package and request.pkg_id not in self.build_tasks: - # Be sure to clear any previous failure spack.store.db.clear_failure(request.spec, force=True) @@ -1948,11 +1942,7 @@ class BuildProcessInstaller(object): # Run post install hooks before build stage is removed. spack.hooks.post_install(self.pkg.spec) - _print_timer( - pre=self.pre, - pkg_id=self.pkg_id, - timer=self.timer, - ) + _print_timer(pre=self.pre, pkg_id=self.pkg_id, timer=self.timer) _print_installed_pkg(self.pkg.prefix) # Send final status that install is successful diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py index 6d0d4bf62f..53779fc878 100644 --- a/lib/spack/spack/modules/common.py +++ b/lib/spack/spack/modules/common.py @@ -249,10 +249,7 @@ def root_path(name, module_set_name): Returns: root folder for module file installation """ - defaults = { - "lmod": "$spack/share/spack/lmod", - "tcl": "$spack/share/spack/modules", - } + defaults = {"lmod": "$spack/share/spack/lmod", "tcl": "$spack/share/spack/modules"} # Root folders where the various module files should be written roots = spack.config.get("modules:%s:roots" % module_set_name, {}) diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index 7c6a2d301b..fd108911a3 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -65,9 +65,7 @@ from spack.util.web import FetchError from spack.version import GitVersion, Version, VersionBase FLAG_HANDLER_RETURN_TYPE = Tuple[ - Optional[Iterable[str]], - Optional[Iterable[str]], - Optional[Iterable[str]], + Optional[Iterable[str]], Optional[Iterable[str]], Optional[Iterable[str]] ] FLAG_HANDLER_TYPE = Callable[[str, Iterable[str]], FLAG_HANDLER_RETURN_TYPE] @@ -1705,11 +1703,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, metaclass=PackageMeta): "don't know how to make {0}. Stop", ] - kwargs = { - "fail_on_error": False, - "output": os.devnull, - "error": str, - } + kwargs = {"fail_on_error": False, "output": os.devnull, "error": str} stderr = make("-n", target, **kwargs) @@ -2220,10 +2214,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, metaclass=PackageMeta): if not force: dependents = spack.store.db.installed_relatives( - spec, - direction="parents", - transitive=True, - deptype=("link", "run"), + spec, direction="parents", transitive=True, deptype=("link", "run") ) if dependents: raise PackageStillNeededError(spec, dependents) @@ -2236,7 +2227,6 @@ class PackageBase(WindowsRPath, PackageViewMixin, metaclass=PackageMeta): # Pre-uninstall hook runs first. with spack.store.db.prefix_write_lock(spec): - if pkg is not None: try: spack.hooks.pre_uninstall(spec) @@ -2399,11 +2389,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, metaclass=PackageMeta): try: return spack.util.web.find_versions_of_archive( - self.all_urls, - self.list_url, - self.list_depth, - concurrency, - reference_package=self, + self.all_urls, self.list_url, self.list_depth, concurrency, reference_package=self ) except spack.util.web.NoNetworkConnectionError as e: tty.die("Package.fetch_versions couldn't connect to:", e.url, e.message) diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py index fd0a2d8cc1..2303bf22a2 100644 --- a/lib/spack/spack/relocate.py +++ b/lib/spack/spack/relocate.py @@ -409,13 +409,7 @@ def needs_text_relocation(m_type, m_subtype): def relocate_macho_binaries( - path_names, - old_layout_root, - new_layout_root, - prefix_to_prefix, - rel, - old_prefix, - new_prefix, + path_names, old_layout_root, new_layout_root, prefix_to_prefix, rel, old_prefix, new_prefix ): """ Use macholib python package to get the rpaths, depedent libraries @@ -829,7 +823,7 @@ def fixup_macos_rpath(root, filename): # Check for nonexistent rpaths (often added by spack linker overzealousness # with both lib/ and lib64/) and duplicate rpaths - for (rpath, count) in rpaths.items(): + for rpath, count in rpaths.items(): if rpath.startswith("@loader_path") or rpath.startswith("@executable_path"): # Allowable relative paths pass diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py index 737467b9fd..b9c3a39a20 100644 --- a/lib/spack/spack/repo.py +++ b/lib/spack/spack/repo.py @@ -1066,7 +1066,6 @@ class Repo(object): # Install patch files needed by the package. fs.mkdirp(path) for patch in itertools.chain.from_iterable(spec.package.patches.values()): - if patch.path: if os.path.exists(patch.path): fs.install(patch.path, path) diff --git a/lib/spack/spack/report.py b/lib/spack/spack/report.py index 1ecbf0d938..00fe7eb5cf 100644 --- a/lib/spack/spack/report.py +++ b/lib/spack/spack/report.py @@ -113,7 +113,6 @@ class InfoCollector: start_time = time.time() try: - value = wrapped_fn(instance, *args, **kwargs) package["stdout"] = self.fetch_log(pkg) package["installed_from_binary_cache"] = pkg.installed_from_binary_cache @@ -234,9 +233,7 @@ class TestInfoCollector(InfoCollector): @contextlib.contextmanager def build_context_manager( - reporter: spack.reporters.Reporter, - filename: str, - specs: List[spack.spec.Spec], + reporter: spack.reporters.Reporter, filename: str, specs: List[spack.spec.Spec] ): """Decorate a package to generate a report after the installation function is executed. diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index dc0e194903..582d6cd4df 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -47,8 +47,7 @@ CDASH_PHASES.add("update") CDashConfiguration = collections.namedtuple( - "CDashConfiguration", - ["upload_url", "packages", "build", "site", "buildstamp", "track"], + "CDashConfiguration", ["upload_url", "packages", "build", "site", "buildstamp", "track"] ) @@ -336,12 +335,7 @@ class CDash(Reporter): if reason: output += "\n{0}".format(reason) - package = { - "name": spec.name, - "id": spec.dag_hash(), - "result": "skipped", - "stdout": output, - } + package = {"name": spec.name, "id": spec.dag_hash(), "result": "skipped", "stdout": output} self.test_report_for_package(directory_name, package, duration=0.0) def concretization_report(self, directory_name, msg): diff --git a/lib/spack/spack/reporters/extract.py b/lib/spack/spack/reporters/extract.py index 9b14d545c6..e31f8d951a 100644 --- a/lib/spack/spack/reporters/extract.py +++ b/lib/spack/spack/reporters/extract.py @@ -10,11 +10,7 @@ from datetime import datetime import llnl.util.tty as tty # The keys here represent the only recognized (ctest/cdash) status values -completed = { - "failed": "Completed", - "passed": "Completed", - "notrun": "No tests to run", -} +completed = {"failed": "Completed", "passed": "Completed", "notrun": "No tests to run"} log_regexp = re.compile(r"^==> \[([0-9:.\-]*)(?:, [0-9]*)?\] (.*)") returns_regexp = re.compile(r"\[([0-9 ,]*)\]") diff --git a/lib/spack/spack/schema/buildcache_spec.py b/lib/spack/spack/schema/buildcache_spec.py index 4ebb31e132..eeeb6dc085 100644 --- a/lib/spack/spack/schema/buildcache_spec.py +++ b/lib/spack/spack/schema/buildcache_spec.py @@ -32,10 +32,7 @@ schema = { }, "binary_cache_checksum": { "type": "object", - "properties": { - "hash_algorithm": {"type": "string"}, - "hash": {"type": "string"}, - }, + "properties": {"hash_algorithm": {"type": "string"}, "hash": {"type": "string"}}, }, "buildcache_layout_version": {"type": "number"}, }, diff --git a/lib/spack/spack/schema/cdash.py b/lib/spack/spack/schema/cdash.py index d4d462596b..5634031b74 100644 --- a/lib/spack/spack/schema/cdash.py +++ b/lib/spack/spack/schema/cdash.py @@ -22,7 +22,7 @@ properties = { r"project": {"type": "string"}, r"site": {"type": "string"}, }, - }, + } } diff --git a/lib/spack/spack/schema/config.py b/lib/spack/spack/schema/config.py index 125279e7a9..7ecd1ad627 100644 --- a/lib/spack/spack/schema/config.py +++ b/lib/spack/spack/schema/config.py @@ -21,7 +21,7 @@ properties = { "flags": { "type": "object", "properties": { - "keep_werror": {"type": "string", "enum": ["all", "specific", "none"]}, + "keep_werror": {"type": "string", "enum": ["all", "specific", "none"]} }, }, "shared_linking": { @@ -54,12 +54,12 @@ properties = { ), }, {"type": "string"}, # deprecated - ], + ] }, "install_hash_length": {"type": "integer", "minimum": 1}, "install_path_scheme": {"type": "string"}, # deprecated "build_stage": { - "oneOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}], + "oneOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}] }, "test_stage": {"type": "string"}, "extensions": {"type": "array", "items": {"type": "string"}}, @@ -82,7 +82,7 @@ properties = { "concretizer": {"type": "string", "enum": ["original", "clingo"]}, "db_lock_timeout": {"type": "integer", "minimum": 1}, "package_lock_timeout": { - "anyOf": [{"type": "integer", "minimum": 1}, {"type": "null"}], + "anyOf": [{"type": "integer", "minimum": 1}, {"type": "null"}] }, "allow_sgid": {"type": "boolean"}, "binary_index_root": {"type": "string"}, @@ -96,7 +96,7 @@ properties = { "modules:[module set]:roots and is ignored", "error": False, }, - }, + } } diff --git a/lib/spack/spack/schema/container.py b/lib/spack/spack/schema/container.py index 92e6953c0e..21d8bba8ef 100644 --- a/lib/spack/spack/schema/container.py +++ b/lib/spack/spack/schema/container.py @@ -62,9 +62,7 @@ container_schema = { "additionalProperties": False, }, # Add labels to the image - "labels": { - "type": "object", - }, + "labels": {"type": "object"}, # Add a custom extra section at the bottom of a stage "extra_instructions": { "type": "object", @@ -83,11 +81,7 @@ container_schema = { "help": {"type": "string"}, }, }, - "docker": { - "type": "object", - "additionalProperties": False, - "default": {}, - }, + "docker": {"type": "object", "additionalProperties": False, "default": {}}, }, } diff --git a/lib/spack/spack/schema/cray_manifest.py b/lib/spack/spack/schema/cray_manifest.py index 42b55cb144..39529fc48f 100644 --- a/lib/spack/spack/schema/cray_manifest.py +++ b/lib/spack/spack/schema/cray_manifest.py @@ -114,9 +114,7 @@ schema = { "prefix": {"type": "string", "minLength": 1}, "rpm": {"type": "string", "minLength": 1}, "hash": {"type": "string", "minLength": 1}, - "parameters": { - "type": "object", - }, + "parameters": {"type": "object"}, }, }, }, diff --git a/lib/spack/spack/schema/database_index.py b/lib/spack/spack/schema/database_index.py index 1a28b73646..021146f92a 100644 --- a/lib/spack/spack/schema/database_index.py +++ b/lib/spack/spack/schema/database_index.py @@ -32,27 +32,17 @@ schema = { "type": "object", "properties": { "spec": spack.schema.spec.properties, - "path": { - "oneOf": [ - {"type": "string"}, - {"type": "null"}, - ], - }, + "path": {"oneOf": [{"type": "string"}, {"type": "null"}]}, "installed": {"type": "boolean"}, - "ref_count": { - "type": "integer", - "minimum": 0, - }, + "ref_count": {"type": "integer", "minimum": 0}, "explicit": {"type": "boolean"}, - "installation_time": { - "type": "number", - }, + "installation_time": {"type": "number"}, }, - }, + } }, }, "version": {"type": "string"}, }, - }, + } }, } diff --git a/lib/spack/spack/schema/env.py b/lib/spack/spack/schema/env.py index a96fe2dbc3..88c1ef1c85 100644 --- a/lib/spack/spack/schema/env.py +++ b/lib/spack/spack/schema/env.py @@ -28,12 +28,7 @@ spec_list_schema = { "properties": { "matrix": { "type": "array", - "items": { - "type": "array", - "items": { - "type": "string", - }, - }, + "items": {"type": "array", "items": {"type": "string"}}, }, "exclude": {"type": "array", "items": {"type": "string"}}, }, @@ -61,11 +56,7 @@ schema = { spack.schema.merged.properties, # extra environment schema properties { - "include": { - "type": "array", - "default": [], - "items": {"type": "string"}, - }, + "include": {"type": "array", "default": [], "items": {"type": "string"}}, "develop": { "type": "object", "default": {}, @@ -78,7 +69,7 @@ schema = { "spec": {"type": "string"}, "path": {"type": "string"}, }, - }, + } }, }, "definitions": { diff --git a/lib/spack/spack/schema/gitlab_ci.py b/lib/spack/spack/schema/gitlab_ci.py index dd46819a46..2f2e51c831 100644 --- a/lib/spack/spack/schema/gitlab_ci.py +++ b/lib/spack/spack/schema/gitlab_ci.py @@ -18,28 +18,16 @@ image_schema = { "type": "object", "properties": { "name": {"type": "string"}, - "entrypoint": { - "type": "array", - "items": { - "type": "string", - }, - }, + "entrypoint": {"type": "array", "items": {"type": "string"}}, }, }, - ], + ] } runner_attributes_schema_items = { "image": image_schema, "tags": {"type": "array", "items": {"type": "string"}}, - "variables": { - "type": "object", - "patternProperties": { - r"[\w\d\-_\.]+": { - "type": "string", - }, - }, - }, + "variables": {"type": "object", "patternProperties": {r"[\w\d\-_\.]+": {"type": "string"}}}, "before_script": {"type": "array", "items": {"type": "string"}}, "script": {"type": "array", "items": {"type": "string"}}, "after_script": {"type": "array", "items": {"type": "string"}}, @@ -56,9 +44,7 @@ remove_attributes_schema = { "type": "object", "additionalProperties": False, "required": ["tags"], - "properties": { - "tags": {"type": "array", "items": {"type": "string"}}, - }, + "properties": {"tags": {"type": "array", "items": {"type": "string"}}}, } @@ -69,24 +55,17 @@ core_shared_properties = union_dicts( "type": "array", "items": { "anyOf": [ - { - "type": "string", - }, + {"type": "string"}, { "type": "object", "additionalProperties": False, "required": ["name"], "properties": { - "name": { - "type": "string", - }, - "compiler-agnostic": { - "type": "boolean", - "default": False, - }, + "name": {"type": "string"}, + "compiler-agnostic": {"type": "boolean", "default": False}, }, }, - ], + ] }, }, "match_behavior": {"type": "string", "enum": ["first", "merge"], "default": "first"}, @@ -97,12 +76,7 @@ core_shared_properties = union_dicts( "additionalProperties": False, "required": ["match"], "properties": { - "match": { - "type": "array", - "items": { - "type": "string", - }, - }, + "match": {"type": "array", "items": {"type": "string"}}, "remove-attributes": remove_attributes_schema, "runner-attributes": runner_selector_schema, }, @@ -112,12 +86,7 @@ core_shared_properties = union_dicts( "signing-job-attributes": runner_selector_schema, "rebuild-index": {"type": "boolean"}, "broken-specs-url": {"type": "string"}, - "broken-tests-packages": { - "type": "array", - "items": { - "type": "string", - }, - }, + "broken-tests-packages": {"type": "array", "items": {"type": "string"}}, }, ) @@ -128,12 +97,7 @@ gitlab_ci_properties = { "additionalProperties": False, "required": ["mappings"], "properties": union_dicts( - core_shared_properties, - { - "enable-artifacts-buildcache": { - "type": "boolean", - }, - }, + core_shared_properties, {"enable-artifacts-buildcache": {"type": "boolean"}} ), }, { @@ -141,21 +105,14 @@ gitlab_ci_properties = { "additionalProperties": False, "required": ["mappings"], "properties": union_dicts( - core_shared_properties, - { - "temporary-storage-url-prefix": { - "type": "string", - }, - }, + core_shared_properties, {"temporary-storage-url-prefix": {"type": "string"}} ), }, ] } #: Properties for inclusion in other schemas -properties = { - "gitlab-ci": gitlab_ci_properties, -} +properties = {"gitlab-ci": gitlab_ci_properties} #: Full schema with metadata schema = { diff --git a/lib/spack/spack/schema/mirrors.py b/lib/spack/spack/schema/mirrors.py index 70222ca10a..41dbddb051 100644 --- a/lib/spack/spack/schema/mirrors.py +++ b/lib/spack/spack/schema/mirrors.py @@ -27,9 +27,9 @@ properties = { }, }, ] - }, + } }, - }, + } } diff --git a/lib/spack/spack/schema/modules.py b/lib/spack/spack/schema/modules.py index 3c0de12b88..975b512c7f 100644 --- a/lib/spack/spack/schema/modules.py +++ b/lib/spack/spack/schema/modules.py @@ -110,10 +110,7 @@ module_config_properties = { "arch_folder": {"type": "boolean"}, "roots": { "type": "object", - "properties": { - "tcl": {"type": "string"}, - "lmod": {"type": "string"}, - }, + "properties": {"tcl": {"type": "string"}, "lmod": {"type": "string"}}, }, "enable": { "type": "array", @@ -165,7 +162,7 @@ properties = { # prefix-relative path to be inspected for existence r"^[\w-]*": array_of_strings }, - }, + } }, "patternProperties": { valid_module_set_name: { @@ -173,7 +170,7 @@ properties = { "default": {}, "additionalProperties": False, "properties": module_config_properties, - }, + } }, } } diff --git a/lib/spack/spack/schema/packages.py b/lib/spack/spack/schema/packages.py index e6d624ed55..1f7c16e2d7 100644 --- a/lib/spack/spack/schema/packages.py +++ b/lib/spack/spack/schema/packages.py @@ -61,25 +61,14 @@ properties = { "default": [], "items": {"type": "string"}, }, # compiler specs - "buildable": { - "type": "boolean", - "default": True, - }, + "buildable": {"type": "boolean", "default": True}, "permissions": { "type": "object", "additionalProperties": False, "properties": { - "read": { - "type": "string", - "enum": ["user", "group", "world"], - }, - "write": { - "type": "string", - "enum": ["user", "group", "world"], - }, - "group": { - "type": "string", - }, + "read": {"type": "string", "enum": ["user", "group", "world"]}, + "write": {"type": "string", "enum": ["user", "group", "world"]}, + "group": {"type": "string"}, }, }, # If 'get_full_repo' is promoted to a Package-level @@ -87,9 +76,7 @@ properties = { "package_attributes": { "type": "object", "additionalProperties": False, - "patternProperties": { - r"\w+": {}, - }, + "patternProperties": {r"\w+": {}}, }, "providers": { "type": "object", @@ -100,14 +87,14 @@ properties = { "type": "array", "default": [], "items": {"type": "string"}, - }, + } }, }, "variants": { "oneOf": [ {"type": "string"}, {"type": "array", "items": {"type": "string"}}, - ], + ] }, "externals": { "type": "array", @@ -124,9 +111,9 @@ properties = { }, }, }, - }, + } }, - }, + } } diff --git a/lib/spack/spack/schema/projections.py b/lib/spack/spack/schema/projections.py index 6d6623a5e7..a28df1c5b5 100644 --- a/lib/spack/spack/schema/projections.py +++ b/lib/spack/spack/schema/projections.py @@ -12,12 +12,7 @@ #: Properties for inclusion in other schemas properties = { - "projections": { - "type": "object", - "patternProperties": { - r"all|\w[\w-]*": {"type": "string"}, - }, - }, + "projections": {"type": "object", "patternProperties": {r"all|\w[\w-]*": {"type": "string"}}} } diff --git a/lib/spack/spack/schema/repos.py b/lib/spack/spack/schema/repos.py index bec1d5a7f0..e846285ca1 100644 --- a/lib/spack/spack/schema/repos.py +++ b/lib/spack/spack/schema/repos.py @@ -11,13 +11,7 @@ #: Properties for inclusion in other schemas -properties = { - "repos": { - "type": "array", - "default": [], - "items": {"type": "string"}, - }, -} +properties = {"repos": {"type": "array", "default": [], "items": {"type": "string"}}} #: Full schema with metadata diff --git a/lib/spack/spack/schema/spec.py b/lib/spack/spack/schema/spec.py index 54a5d990a3..8d2390b2f3 100644 --- a/lib/spack/spack/schema/spec.py +++ b/lib/spack/spack/schema/spec.py @@ -14,44 +14,26 @@ TODO: This needs to be updated? Especially the hashes under properties. target = { "oneOf": [ - { - "type": "string", - }, + {"type": "string"}, { "type": "object", "additionalProperties": False, - "required": [ - "name", - "vendor", - "features", - "generation", - "parents", - ], + "required": ["name", "vendor", "features", "generation", "parents"], "properties": { "name": {"type": "string"}, "vendor": {"type": "string"}, - "features": { - "type": "array", - "items": {"type": "string"}, - }, + "features": {"type": "array", "items": {"type": "string"}}, "generation": {"type": "integer"}, - "parents": { - "type": "array", - "items": {"type": "string"}, - }, + "parents": {"type": "array", "items": {"type": "string"}}, }, }, - ], + ] } arch = { "type": "object", "additionalProperties": False, - "properties": { - "platform": {}, - "platform_os": {}, - "target": target, - }, + "properties": {"platform": {}, "platform_os": {}, "target": target}, } dependencies = { @@ -61,12 +43,9 @@ dependencies = { "type": "object", "properties": { "hash": {"type": "string"}, - "type": { - "type": "array", - "items": {"type": "string"}, - }, + "type": {"type": "array", "items": {"type": "string"}}, }, - }, + } }, } @@ -90,13 +69,7 @@ properties = { "items": { "type": "object", "additionalProperties": False, - "required": [ - "version", - "arch", - "compiler", - "namespace", - "parameters", - ], + "required": ["version", "arch", "compiler", "namespace", "parameters"], "properties": { "name": {"type": "string"}, "hash": {"type": "string"}, @@ -104,12 +77,7 @@ properties = { # these hashes were used on some specs prior to 0.18 "full_hash": {"type": "string"}, "build_hash": {"type": "string"}, - "version": { - "oneOf": [ - {"type": "string"}, - {"type": "number"}, - ], - }, + "version": {"oneOf": [{"type": "string"}, {"type": "number"}]}, "arch": arch, "compiler": { "type": "object", @@ -119,12 +87,7 @@ properties = { "version": {"type": "string"}, }, }, - "develop": { - "anyOf": [ - {"type": "boolean"}, - {"type": "string"}, - ], - }, + "develop": {"anyOf": [{"type": "boolean"}, {"type": "string"}]}, "namespace": {"type": "string"}, "parameters": { "type": "object", @@ -138,40 +101,16 @@ properties = { ], "additionalProperties": True, "properties": { - "patches": { - "type": "array", - "items": {"type": "string"}, - }, - "cflags": { - "type": "array", - "items": {"type": "string"}, - }, - "cppflags": { - "type": "array", - "items": {"type": "string"}, - }, - "cxxflags": { - "type": "array", - "items": {"type": "string"}, - }, - "fflags": { - "type": "array", - "items": {"type": "string"}, - }, - "ldflags": { - "type": "array", - "items": {"type": "string"}, - }, - "ldlib": { - "type": "array", - "items": {"type": "string"}, - }, + "patches": {"type": "array", "items": {"type": "string"}}, + "cflags": {"type": "array", "items": {"type": "string"}}, + "cppflags": {"type": "array", "items": {"type": "string"}}, + "cxxflags": {"type": "array", "items": {"type": "string"}}, + "fflags": {"type": "array", "items": {"type": "string"}}, + "ldflags": {"type": "array", "items": {"type": "string"}}, + "ldlib": {"type": "array", "items": {"type": "string"}}, }, }, - "patches": { - "type": "array", - "items": {}, - }, + "patches": {"type": "array", "items": {}}, "dependencies": dependencies, "build_spec": build_spec, }, diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 527377127c..673e202afa 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -112,8 +112,7 @@ version_origin_str = {i: name for i, name in enumerate(version_origin_fields)} #: Enumeration like object to mark version provenance version_provenance = collections.namedtuple( # type: ignore - "VersionProvenance", - version_origin_fields, + "VersionProvenance", version_origin_fields )(**{name: i for i, name in enumerate(version_origin_fields)}) #: Named tuple to contain information on declared versions @@ -1138,8 +1137,7 @@ class SpackSolverSetup(object): # virtual preferences self.virtual_preferences( - pkg.name, - lambda v, p, i: self.gen.fact(fn.pkg_provider_preference(pkg.name, v, p, i)), + pkg.name, lambda v, p, i: self.gen.fact(fn.pkg_provider_preference(pkg.name, v, p, i)) ) self.package_requirement_rules(pkg) @@ -1248,8 +1246,7 @@ class SpackSolverSetup(object): ) assert self.possible_virtuals is not None, msg self.virtual_preferences( - "all", - lambda v, p, i: self.gen.fact(fn.default_provider_preference(v, p, i)), + "all", lambda v, p, i: self.gen.fact(fn.default_provider_preference(v, p, i)) ) def provider_requirements(self): @@ -1427,12 +1424,7 @@ class SpackSolverSetup(object): return clauses def _spec_clauses( - self, - spec, - body=False, - transitive=True, - expand_hashes=False, - concrete_build_deps=False, + self, spec, body=False, transitive=True, expand_hashes=False, concrete_build_deps=False ): """Return a list of clauses for a spec mandates are true. @@ -2521,15 +2513,7 @@ class Solver(object): pass return reusable_specs - def solve( - self, - specs, - out=None, - timers=False, - stats=False, - tests=False, - setup_only=False, - ): + def solve(self, specs, out=None, timers=False, stats=False, tests=False, setup_only=False): """ Arguments: specs (list): List of ``Spec`` objects to solve for. @@ -2549,14 +2533,7 @@ class Solver(object): result, _, _ = self.driver.solve(setup, specs, reuse=reusable_specs, output=output) return result - def solve_in_rounds( - self, - specs, - out=None, - timers=False, - stats=False, - tests=False, - ): + def solve_in_rounds(self, specs, out=None, timers=False, stats=False, tests=False): """Solve for a stable model of specs in multiple rounds. This relaxes the assumption of solve that everything must be consistent and diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index aaeb15e82e..94e3230285 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -229,6 +229,7 @@ class ArchSpec(object): Otherwise information on platform, OS and target should be passed in either as a spec string or as a tuple. """ + # If the argument to __init__ is a spec string, parse it # and construct an ArchSpec def _string_or_none(s): @@ -731,7 +732,6 @@ _valid_compiler_flags = ["cflags", "cxxflags", "fflags", "ldflags", "ldlibs", "c class FlagMap(lang.HashableMap): - __slots__ = ("spec",) def __init__(self, spec): @@ -1221,7 +1221,6 @@ class SpecBuildInterface(lang.ObjectWrapper): @lang.lazy_lexicographic_ordering(set_hash=False) class Spec(object): - #: Cache for spec's prefix, computed lazily in the corresponding property _prefix = None @@ -1550,12 +1549,7 @@ class Spec(object): "Cannot depend on incompatible specs '%s' and '%s'" % (dspec.spec, spec) ) - def add_dependency_edge( - self, - dependency_spec: "Spec", - *, - deptypes: dp.DependencyArgument, - ): + def add_dependency_edge(self, dependency_spec: "Spec", *, deptypes: dp.DependencyArgument): """Add a dependency edge to this spec. Args: @@ -2241,7 +2235,6 @@ class Spec(object): # Recurse on dependencies for s, s_dependencies in dep_like.items(): - if isinstance(s, str): dag_node, dependency_types = name_and_dependency_types(s) else: @@ -2897,7 +2890,6 @@ class Spec(object): try: deptree = self.traverse(root=False) for spec in deptree: - if spec.name not in flat_deps: if copy: spec = spec.copy(deps=False) @@ -5245,7 +5237,6 @@ class ConflictsInSpecError(spack.error.SpecError, RuntimeError): match_fmt_custom = '{0}. "{1}" conflicts with "{2}" [{3}]\n' for idx, (s, c, w, msg) in enumerate(matches): - if s not in visited: visited.add(s) long_message += "List of matching conflicts for spec:\n\n" diff --git a/lib/spack/spack/test/bindist.py b/lib/spack/spack/test/bindist.py index dc9003d42a..d959258c85 100644 --- a/lib/spack/spack/test/bindist.py +++ b/lib/spack/spack/test/bindist.py @@ -416,11 +416,7 @@ def test_spec_needs_rebuild(monkeypatch, tmpdir): assert rebuild -@pytest.mark.usefixtures( - "install_mockery_mutable_config", - "mock_packages", - "mock_fetch", -) +@pytest.mark.usefixtures("install_mockery_mutable_config", "mock_packages", "mock_fetch") def test_generate_index_missing(monkeypatch, tmpdir, mutable_config): """Ensure spack buildcache index only reports available packages""" diff --git a/lib/spack/spack/test/bootstrap.py b/lib/spack/spack/test/bootstrap.py index f779ff9b72..7eee7a21e3 100644 --- a/lib/spack/spack/test/bootstrap.py +++ b/lib/spack/spack/test/bootstrap.py @@ -67,18 +67,12 @@ def test_raising_exception_if_bootstrap_disabled(mutable_config): def test_raising_exception_module_importable(): - with pytest.raises( - ImportError, - match='cannot bootstrap the "asdf" Python module', - ): + with pytest.raises(ImportError, match='cannot bootstrap the "asdf" Python module'): spack.bootstrap.core.ensure_module_importable_or_raise("asdf") def test_raising_exception_executables_in_path(): - with pytest.raises( - RuntimeError, - match="cannot bootstrap any of the asdf, fdsa executables", - ): + with pytest.raises(RuntimeError, match="cannot bootstrap any of the asdf, fdsa executables"): spack.bootstrap.core.ensure_executables_in_path_or_raise(["asdf", "fdsa"], "python") diff --git a/lib/spack/spack/test/build_distribution.py b/lib/spack/spack/test/build_distribution.py index e9d0723d91..490f539845 100644 --- a/lib/spack/spack/test/build_distribution.py +++ b/lib/spack/spack/test/build_distribution.py @@ -20,7 +20,6 @@ pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="does not run on def test_build_tarball_overwrite(install_mockery, mock_fetch, monkeypatch, tmpdir): - with tmpdir.as_cwd(): spec = spack.spec.Spec("trivial-install-test-package").concretized() install(str(spec)) diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py index 8ddeadd384..e0ab530fa8 100644 --- a/lib/spack/spack/test/build_environment.py +++ b/lib/spack/spack/test/build_environment.py @@ -17,11 +17,7 @@ import spack.config import spack.package_base import spack.spec import spack.util.spack_yaml as syaml -from spack.build_environment import ( - _static_to_shared_library, - determine_number_of_jobs, - dso_suffix, -) +from spack.build_environment import _static_to_shared_library, determine_number_of_jobs, dso_suffix from spack.paths import build_env_path from spack.util.environment import EnvironmentModifications from spack.util.executable import Executable @@ -160,7 +156,6 @@ def test_static_to_shared_library(build_environment): @pytest.mark.regression("8345") @pytest.mark.usefixtures("config", "mock_packages") def test_cc_not_changed_by_modules(monkeypatch, working_env): - s = spack.spec.Spec("cmake") s.concretize() pkg = s.package diff --git a/lib/spack/spack/test/builder.py b/lib/spack/spack/test/builder.py index ff11aec185..40d32c6e79 100644 --- a/lib/spack/spack/test/builder.py +++ b/lib/spack/spack/test/builder.py @@ -63,32 +63,12 @@ def builder_test_repository(): # Generate custom phases using a GenericBuilder ( "custom-phases", - [ - ("CONFIGURE_CALLED", "1"), - ("INSTALL_CALLED", "1"), - ("LAST_PHASE", "INSTALL"), - ], + [("CONFIGURE_CALLED", "1"), ("INSTALL_CALLED", "1"), ("LAST_PHASE", "INSTALL")], ), # Old-style package, with phase defined in base builder - ( - "old-style-autotools@1.0", - [ - ("AFTER_AUTORECONF_1_CALLED", "1"), - ], - ), - ( - "old-style-autotools@2.0", - [ - ("AFTER_AUTORECONF_2_CALLED", "1"), - ], - ), - ( - "old-style-custom-phases", - [ - ("AFTER_CONFIGURE_CALLED", "1"), - ("TEST_VALUE", "0"), - ], - ), + ("old-style-autotools@1.0", [("AFTER_AUTORECONF_1_CALLED", "1")]), + ("old-style-autotools@2.0", [("AFTER_AUTORECONF_2_CALLED", "1")]), + ("old-style-custom-phases", [("AFTER_CONFIGURE_CALLED", "1"), ("TEST_VALUE", "0")]), ], ) @pytest.mark.usefixtures("builder_test_repository", "config") diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py index afee60369d..3589eb49f8 100644 --- a/lib/spack/spack/test/cc.py +++ b/lib/spack/spack/test/cc.py @@ -514,7 +514,6 @@ def test_ccld_with_system_dirs(wrapper_environment): SPACK_RPATH_DIRS="xlib:ylib:zlib", SPACK_LINK_DIRS="xlib:ylib:zlib", ): - sys_path_args = [ "-I/usr/include", "-L/usr/local/lib", @@ -551,7 +550,6 @@ def test_ccld_with_system_dirs_isystem(wrapper_environment): SPACK_RPATH_DIRS="xlib:ylib:zlib", SPACK_LINK_DIRS="xlib:ylib:zlib", ): - sys_path_args = [ "-isystem", "/usr/include", @@ -717,15 +715,9 @@ def test_keep_and_replace(wrapper_environment): werror_specific = ["-Werror=meh"] werror = ["-Werror"] werror_all = werror_specific + werror - with set_env( - SPACK_COMPILER_FLAGS_KEEP="", - SPACK_COMPILER_FLAGS_REPLACE="-Werror*|", - ): + with set_env(SPACK_COMPILER_FLAGS_KEEP="", SPACK_COMPILER_FLAGS_REPLACE="-Werror*|"): check_args_contents(cc, test_args + werror_all, ["-Wl,--end-group"], werror_all) - with set_env( - SPACK_COMPILER_FLAGS_KEEP="-Werror=*", - SPACK_COMPILER_FLAGS_REPLACE="-Werror*|", - ): + with set_env(SPACK_COMPILER_FLAGS_KEEP="-Werror=*", SPACK_COMPILER_FLAGS_REPLACE="-Werror*|"): check_args_contents(cc, test_args + werror_all, werror_specific, werror) with set_env( SPACK_COMPILER_FLAGS_KEEP="-Werror=*", diff --git a/lib/spack/spack/test/ci.py b/lib/spack/spack/test/ci.py index 927a283247..7d49c15c8d 100644 --- a/lib/spack/spack/test/ci.py +++ b/lib/spack/spack/test/ci.py @@ -84,7 +84,6 @@ class FakeWebResponder(object): return self._resp_code def read(self, length=None): - if len(self._content) <= 0: return None @@ -103,11 +102,7 @@ class FakeWebResponder(object): def test_download_and_extract_artifacts(tmpdir, monkeypatch, working_env): - os.environ.update( - { - "GITLAB_PRIVATE_TOKEN": "faketoken", - } - ) + os.environ.update({"GITLAB_PRIVATE_TOKEN": "faketoken"}) url = "https://www.nosuchurlexists.itsfake/artifacts.zip" working_dir = os.path.join(tmpdir.strpath, "repro") @@ -234,24 +229,14 @@ def test_setup_spack_repro_version(tmpdir, capfd, last_two_git_commits, monkeypa assert "Unable to merge {0}".format(c1) in err -@pytest.mark.parametrize( - "obj, proto", - [ - ({}, []), - ], -) +@pytest.mark.parametrize("obj, proto", [({}, [])]) def test_ci_opt_argument_checking(obj, proto): """Check that matches() and subkeys() return False when `proto` is not a dict.""" assert not ci_opt.matches(obj, proto) assert not ci_opt.subkeys(obj, proto) -@pytest.mark.parametrize( - "yaml", - [ - {"extends": 1}, - ], -) +@pytest.mark.parametrize("yaml", [{"extends": 1}]) def test_ci_opt_add_extends_non_sequence(yaml): """Check that add_extends() exits if 'extends' is not a sequence.""" yaml_copy = yaml.copy() @@ -263,10 +248,7 @@ def test_ci_workarounds(): fake_root_spec = "x" * 544 fake_spack_ref = "x" * 40 - common_variables = { - "SPACK_COMPILER_ACTION": "NONE", - "SPACK_IS_PR_PIPELINE": "False", - } + common_variables = {"SPACK_COMPILER_ACTION": "NONE", "SPACK_IS_PR_PIPELINE": "False"} common_before_script = [ 'git clone "https://github.com/spack/spack"', @@ -307,7 +289,6 @@ def test_ci_workarounds(): return {name: result} def make_rebuild_index_job(use_artifact_buildcache, optimize, use_dependencies): - result = { "stage": "stage-rebuild-index", "script": "spack buildcache update-index --mirror-url s3://mirror", diff --git a/lib/spack/spack/test/cmd/audit.py b/lib/spack/spack/test/cmd/audit.py index 43e0870c1c..493cf9ff36 100644 --- a/lib/spack/spack/test/cmd/audit.py +++ b/lib/spack/spack/test/cmd/audit.py @@ -35,7 +35,6 @@ def test_audit_configs(mutable_config, mock_packages): def test_audit_packages_https(mutable_config, mock_packages): - # Without providing --all should fail audit("packages-https", fail_on_error=False) # The mock configuration has duplicate definitions of some compilers diff --git a/lib/spack/spack/test/cmd/build_env.py b/lib/spack/spack/test/cmd/build_env.py index 705c7a8d56..2efc59fb8e 100644 --- a/lib/spack/spack/test/cmd/build_env.py +++ b/lib/spack/spack/test/cmd/build_env.py @@ -23,14 +23,7 @@ def test_error_when_multiple_specs_are_given(): assert "only takes one spec" in output -@pytest.mark.parametrize( - "args", - [ - ("--", "/bin/bash", "-c", "echo test"), - ("--",), - (), - ], -) +@pytest.mark.parametrize("args", [("--", "/bin/bash", "-c", "echo test"), ("--",), ()]) @pytest.mark.usefixtures("config", "mock_packages", "working_env") def test_build_env_requires_a_spec(args): output = build_env(*args, fail_on_error=False) diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index f5a3185599..5a05aa1d94 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -258,12 +258,7 @@ def _validate_needs_graph(yaml_contents, needs_graph, artifacts): def test_ci_generate_bootstrap_gcc( - tmpdir, - working_env, - mutable_mock_env_path, - install_mockery, - mock_packages, - ci_base_environment, + tmpdir, working_env, mutable_mock_env_path, install_mockery, mock_packages, ci_base_environment ): """Test that we can bootstrap a compiler and use it as the compiler for a spec in the environment""" @@ -300,21 +295,10 @@ spack: needs_graph = { "(bootstrap) conflict": [], - "(bootstrap) gcc": [ - "(bootstrap) conflict", - ], - "(specs) libelf": [ - "(bootstrap) gcc", - ], - "(specs) libdwarf": [ - "(bootstrap) gcc", - "(specs) libelf", - ], - "(specs) dyninst": [ - "(bootstrap) gcc", - "(specs) libelf", - "(specs) libdwarf", - ], + "(bootstrap) gcc": ["(bootstrap) conflict"], + "(specs) libelf": ["(bootstrap) gcc"], + "(specs) libdwarf": ["(bootstrap) gcc", "(specs) libelf"], + "(specs) dyninst": ["(bootstrap) gcc", "(specs) libelf", "(specs) libdwarf"], } with tmpdir.as_cwd(): @@ -331,12 +315,7 @@ spack: def test_ci_generate_bootstrap_artifacts_buildcache( - tmpdir, - working_env, - mutable_mock_env_path, - install_mockery, - mock_packages, - ci_base_environment, + tmpdir, working_env, mutable_mock_env_path, install_mockery, mock_packages, ci_base_environment ): """Test that we can bootstrap a compiler when artifacts buildcache is turned on""" @@ -373,18 +352,9 @@ spack: needs_graph = { "(bootstrap) conflict": [], - "(bootstrap) gcc": [ - "(bootstrap) conflict", - ], - "(specs) libelf": [ - "(bootstrap) gcc", - "(bootstrap) conflict", - ], - "(specs) libdwarf": [ - "(bootstrap) gcc", - "(bootstrap) conflict", - "(specs) libelf", - ], + "(bootstrap) gcc": ["(bootstrap) conflict"], + "(specs) libelf": ["(bootstrap) gcc", "(bootstrap) conflict"], + "(specs) libdwarf": ["(bootstrap) gcc", "(bootstrap) conflict", "(specs) libelf"], "(specs) dyninst": [ "(bootstrap) gcc", "(bootstrap) conflict", @@ -447,11 +417,7 @@ def test_ci_generate_with_cdash_token( mock_binary_index, ): """Make sure we it doesn't break if we configure cdash""" - os.environ.update( - { - "SPACK_CDASH_AUTH_TOKEN": "notreallyatokenbutshouldnotmatter", - } - ) + os.environ.update({"SPACK_CDASH_AUTH_TOKEN": "notreallyatokenbutshouldnotmatter"}) filename = str(tmpdir.join("spack.yaml")) with open(filename, "w") as f: f.write( @@ -598,12 +564,7 @@ spack: def test_ci_generate_pkg_with_deps( - tmpdir, - working_env, - mutable_mock_env_path, - install_mockery, - mock_packages, - ci_base_environment, + tmpdir, working_env, mutable_mock_env_path, install_mockery, mock_packages, ci_base_environment ): """Test pipeline generation for a package w/ dependencies""" filename = str(tmpdir.join("spack.yaml")) @@ -670,10 +631,7 @@ def test_ci_generate_for_pr_pipeline( rebuilding the mirror index, even if that job is specifically configured""" os.environ.update( - { - "SPACK_PIPELINE_TYPE": "spack_pull_request", - "SPACK_PR_BRANCH": "fake-test-branch", - } + {"SPACK_PIPELINE_TYPE": "spack_pull_request", "SPACK_PR_BRANCH": "fake-test-branch"} ) filename = str(tmpdir.join("spack.yaml")) with open(filename, "w") as f: @@ -928,7 +886,6 @@ def test_ci_rebuild_mock_success( monkeypatch, broken_tests, ): - pkg_name = "archive-files" rebuild_env = create_rebuild_env(tmpdir, pkg_name, broken_tests) @@ -1129,11 +1086,7 @@ def test_ci_generate_mirror_override( """Ensure that protected pipelines using --buildcache-destination do not skip building specs that are not in the override mirror when they are found in the main mirror.""" - os.environ.update( - { - "SPACK_PIPELINE_TYPE": "spack_protected_branch", - } - ) + os.environ.update({"SPACK_PIPELINE_TYPE": "spack_protected_branch"}) working_dir = tmpdir.join("working_dir") @@ -1727,12 +1680,7 @@ spack: if spec.name == "gcc": return [] else: - return [ - { - "spec": spec, - "mirror_url": mirror_url, - } - ] + return [{"spec": spec, "mirror_url": mirror_url}] with tmpdir.as_cwd(): env_cmd("create", "test", "./spack.yaml") @@ -1766,12 +1714,7 @@ spack: # not otherwise need to be rebuilt (thanks to DAG pruning), they # both end up in the generated pipeline because the compiler they # depend on is bootstrapped, and *does* need to be rebuilt. - needs_graph = { - "(bootstrap) gcc": [], - "(specs) b": [ - "(bootstrap) gcc", - ], - } + needs_graph = {"(bootstrap) gcc": [], "(specs) b": ["(bootstrap) gcc"]} _validate_needs_graph(new_yaml_contents, needs_graph, False) @@ -1788,11 +1731,7 @@ def test_ci_generate_prune_untouched( ): """Test pipeline generation with pruning works to eliminate specs that were not affected by a change""" - os.environ.update( - { - "SPACK_PRUNE_UNTOUCHED": "TRUE", # enables pruning of untouched specs - } - ) + os.environ.update({"SPACK_PRUNE_UNTOUCHED": "TRUE"}) # enables pruning of untouched specs mirror_url = "https://my.fake.mirror" filename = str(tmpdir.join("spack.yaml")) with open(filename, "w") as f: @@ -2216,14 +2155,7 @@ spack: @pytest.mark.parametrize( - "subcmd", - [ - (""), - ("generate"), - ("rebuild-index"), - ("rebuild"), - ("reproduce-build"), - ], + "subcmd", [(""), ("generate"), ("rebuild-index"), ("rebuild"), ("reproduce-build")] ) def test_ci_help(subcmd, capsys): """Make sure `spack ci` --help describes the (sub)command help.""" diff --git a/lib/spack/spack/test/cmd/clean.py b/lib/spack/spack/test/cmd/clean.py index 43484a680d..51a4e104c2 100644 --- a/lib/spack/spack/test/cmd/clean.py +++ b/lib/spack/spack/test/cmd/clean.py @@ -22,7 +22,6 @@ pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="does not run on @pytest.fixture() def mock_calls_for_clean(monkeypatch): - counts = {} class Counter(object): @@ -61,7 +60,6 @@ all_effects = ["stages", "downloads", "caches", "failures", "python_cache"] ], ) def test_function_calls(command_line, effects, mock_calls_for_clean): - # Call the command with the supplied command line clean(command_line) diff --git a/lib/spack/spack/test/cmd/commands.py b/lib/spack/spack/test/cmd/commands.py index 24f11e84ae..1477aa4859 100644 --- a/lib/spack/spack/test/cmd/commands.py +++ b/lib/spack/spack/test/cmd/commands.py @@ -195,7 +195,7 @@ def test_update_completion_arg(tmpdir, monkeypatch): "format": "bash", "header": str(mock_infile), "update": str(mock_bashfile), - }, + } } # make a mock completion file missing the --update-completion argument diff --git a/lib/spack/spack/test/cmd/compiler.py b/lib/spack/spack/test/cmd/compiler.py index bdb61abf93..796285a184 100644 --- a/lib/spack/spack/test/cmd/compiler.py +++ b/lib/spack/spack/test/cmd/compiler.py @@ -271,10 +271,7 @@ def test_compiler_find_path_order(no_compilers_yaml, working_env, clangdir): shutil.copy("gfortran-8", "first_in_path/gfortran-8") # the first_in_path folder should be searched first - os.environ["PATH"] = "{0}:{1}".format( - str(clangdir.join("first_in_path")), - str(clangdir), - ) + os.environ["PATH"] = "{0}:{1}".format(str(clangdir.join("first_in_path")), str(clangdir)) compiler("find", "--scope=site") diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py index 86e03028bd..081e1dfefb 100644 --- a/lib/spack/spack/test/cmd/config.py +++ b/lib/spack/spack/test/cmd/config.py @@ -33,10 +33,7 @@ def _create_config(scope=None, data={}, section="packages"): def config_yaml_v015(mutable_config): """Create a packages.yaml in the old format""" old_data = { - "config": { - "install_tree": "/fake/path", - "install_path_scheme": "{name}-{version}", - } + "config": {"install_tree": "/fake/path", "install_path_scheme": "{name}-{version}"} } return functools.partial(_create_config, data=old_data, section="config") @@ -232,7 +229,6 @@ def test_config_add_update_dict(mutable_empty_config): def test_config_with_c_argument(mutable_empty_config): - # I don't know how to add a spack argument to a Spack Command, so we test this way config_file = "config:install_root:root:/path/to/config.yaml" parser = spack.main.make_argument_parser() diff --git a/lib/spack/spack/test/cmd/create.py b/lib/spack/spack/test/cmd/create.py index f8bc61adf5..ed7a6404bb 100644 --- a/lib/spack/spack/test/cmd/create.py +++ b/lib/spack/spack/test/cmd/create.py @@ -143,11 +143,7 @@ def test_create_template(mock_test_repo, args, name, expected): @pytest.mark.parametrize( - "name,expected", - [ - (" ", "name must be provided"), - ("bad#name", "name can only contain"), - ], + "name,expected", [(" ", "name must be provided"), ("bad#name", "name can only contain")] ) def test_create_template_bad_name(mock_test_repo, name, expected): """Test template creation with bad name options.""" @@ -184,11 +180,7 @@ def test_build_system_guesser_octave(): @pytest.mark.parametrize( - "url,expected", - [ - ("testname", "testname"), - ("file://example.com/archive.tar.gz", "archive"), - ], + "url,expected", [("testname", "testname"), ("file://example.com/archive.tar.gz", "archive")] ) def test_get_name_urls(url, expected): """Test get_name with different URLs.""" diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index 19b53c0573..dc183a84f4 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -627,7 +627,6 @@ packages: test_scope = spack.config.InternalConfigScope("env-external-test", data=external_config_dict) with spack.config.override(test_scope): - e = ev.create("test", initial_yaml) e.concretize() # Note: normally installing specs in a test environment requires doing @@ -2763,12 +2762,7 @@ def test_query_develop_specs(): @pytest.mark.parametrize("method", [spack.cmd.env.env_activate, spack.cmd.env.env_deactivate]) @pytest.mark.parametrize( - "env,no_env,env_dir", - [ - ("b", False, None), - (None, True, None), - (None, False, "path/"), - ], + "env,no_env,env_dir", [("b", False, None), (None, True, None), (None, False, "path/")] ) def test_activation_and_deactiviation_ambiguities(method, env, no_env, env_dir, capsys): """spack [-e x | -E | -D x/] env [activate | deactivate] y are ambiguous""" @@ -3071,15 +3065,7 @@ def test_read_legacy_lockfile_and_reconcretize(mock_stage, mock_fetch, install_m # This prunes all build deps ( ["--use-buildcache=only"], - [ - "dtlink1", - "dtlink3", - "dtlink4", - "dtlink5", - "dtrun1", - "dtrun3", - "dttop", - ], + ["dtlink1", "dtlink3", "dtlink4", "dtlink5", "dtrun1", "dtrun3", "dttop"], ), # Test whether pruning of build deps is correct if we explicitly include one # that is also a dependency of a root. diff --git a/lib/spack/spack/test/cmd/extensions.py b/lib/spack/spack/test/cmd/extensions.py index c7f638fe44..c1bfc2b153 100644 --- a/lib/spack/spack/test/cmd/extensions.py +++ b/lib/spack/spack/test/cmd/extensions.py @@ -15,14 +15,7 @@ extensions = SpackCommand("extensions") @pytest.fixture def python_database(mock_packages, mutable_database): - specs = [ - Spec(s).concretized() - for s in [ - "python", - "py-extension1", - "py-extension2", - ] - ] + specs = [Spec(s).concretized() for s in ["python", "py-extension1", "py-extension2"]] for spec in specs: spec.package.do_install(fake=True, explicit=True) diff --git a/lib/spack/spack/test/cmd/external.py b/lib/spack/spack/test/cmd/external.py index 9f3ff2f688..12b9d405c6 100644 --- a/lib/spack/spack/test/cmd/external.py +++ b/lib/spack/spack/test/cmd/external.py @@ -383,13 +383,7 @@ def test_new_entries_are_reported_correctly( assert "No new external packages detected" in output -@pytest.mark.parametrize( - "command_args", - [ - ("-t", "build-tools"), - ("-t", "build-tools", "cmake"), - ], -) +@pytest.mark.parametrize("command_args", [("-t", "build-tools"), ("-t", "build-tools", "cmake")]) def test_use_tags_for_detection(command_args, mock_executable, mutable_config, monkeypatch): # Prepare an environment to detect a fake cmake cmake_exe = mock_executable("cmake", output="echo cmake version 3.19.1") diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py index 17153f998f..5c520a97e1 100644 --- a/lib/spack/spack/test/cmd/find.py +++ b/lib/spack/spack/test/cmd/find.py @@ -90,7 +90,6 @@ def test_query_arguments(): @pytest.mark.db @pytest.mark.usefixtures("database", "mock_display") def test_tag1(parser, specs): - args = parser.parse_args(["--tag", "tag1"]) spack.cmd.find.find(parser, args) @@ -196,12 +195,7 @@ def test_find_json_deps(database): @pytest.mark.db def test_display_json(database, capsys): specs = [ - Spec(s).concretized() - for s in [ - "mpileaks ^zmpi", - "mpileaks ^mpich", - "mpileaks ^mpich2", - ] + Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] ] cmd.display_specs_as_json(specs) @@ -216,12 +210,7 @@ def test_display_json(database, capsys): @pytest.mark.db def test_display_json_deps(database, capsys): specs = [ - Spec(s).concretized() - for s in [ - "mpileaks ^zmpi", - "mpileaks ^mpich", - "mpileaks ^mpich2", - ] + Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] ] cmd.display_specs_as_json(specs, deps=True) @@ -237,31 +226,19 @@ def test_display_json_deps(database, capsys): def test_find_format(database, config): output = find("--format", "{name}-{^mpi.name}", "mpileaks") assert set(output.strip().split("\n")) == set( - [ - "mpileaks-zmpi", - "mpileaks-mpich", - "mpileaks-mpich2", - ] + ["mpileaks-zmpi", "mpileaks-mpich", "mpileaks-mpich2"] ) output = find("--format", "{name}-{version}-{compiler.name}-{^mpi.name}", "mpileaks") assert "installed package" not in output assert set(output.strip().split("\n")) == set( - [ - "mpileaks-2.3-gcc-zmpi", - "mpileaks-2.3-gcc-mpich", - "mpileaks-2.3-gcc-mpich2", - ] + ["mpileaks-2.3-gcc-zmpi", "mpileaks-2.3-gcc-mpich", "mpileaks-2.3-gcc-mpich2"] ) output = find("--format", "{name}-{^mpi.name}-{hash:7}", "mpileaks") elements = output.strip().split("\n") assert set(e[:-7] for e in elements) == set( - [ - "mpileaks-zmpi-", - "mpileaks-mpich-", - "mpileaks-mpich2-", - ] + ["mpileaks-zmpi-", "mpileaks-mpich-", "mpileaks-mpich2-"] ) # hashes are in base32 @@ -317,12 +294,7 @@ def test_find_very_long(database, config): output = find("-L", "--no-groups", "mpileaks") specs = [ - Spec(s).concretized() - for s in [ - "mpileaks ^zmpi", - "mpileaks ^mpich", - "mpileaks ^mpich2", - ] + Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] ] assert set(output.strip().split("\n")) == set( diff --git a/lib/spack/spack/test/cmd/info.py b/lib/spack/spack/test/cmd/info.py index 5f43fcc06d..801a69cbde 100644 --- a/lib/spack/spack/test/cmd/info.py +++ b/lib/spack/spack/test/cmd/info.py @@ -59,11 +59,7 @@ def test_info_noversion(mock_packages, print_buffer): @pytest.mark.parametrize( - "pkg_query,expected", - [ - ("zlib", "False"), - ("gcc", "True (version, variants)"), - ], + "pkg_query,expected", [("zlib", "False"), ("gcc", "True (version, variants)")] ) def test_is_externally_detectable(pkg_query, expected, parser, print_buffer): args = parser.parse_args(["--detectable", pkg_query]) diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index dd95967dbe..8074cfe0dc 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -51,7 +51,6 @@ def noop_install(monkeypatch): def test_install_package_and_dependency( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery ): - log = "test" with tmpdir.as_cwd(): install("--log-format=junit", "--log-file={0}".format(log), "libdwarf") @@ -96,7 +95,6 @@ def test_install_runtests_all(monkeypatch, mock_packages, install_mockery): def test_install_package_already_installed( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery ): - with tmpdir.as_cwd(): install("libdwarf") install("--log-format=junit", "--log-file=test.xml", "libdwarf") @@ -242,11 +240,7 @@ def test_install_overwrite(mock_packages, mock_archive, mock_fetch, config, inst def test_install_overwrite_not_installed( - mock_packages, - mock_archive, - mock_fetch, - config, - install_mockery, + mock_packages, mock_archive, mock_fetch, config, install_mockery ): # Try to install a spec and then to reinstall it. spec = Spec("libdwarf") @@ -342,11 +336,7 @@ def test_install_overwrite_multiple( @pytest.mark.usefixtures( - "mock_packages", - "mock_archive", - "mock_fetch", - "config", - "install_mockery", + "mock_packages", "mock_archive", "mock_fetch", "config", "install_mockery" ) def test_install_conflicts(conflict_spec): # Make sure that spec with conflicts raises a SpackError @@ -355,11 +345,7 @@ def test_install_conflicts(conflict_spec): @pytest.mark.usefixtures( - "mock_packages", - "mock_archive", - "mock_fetch", - "config", - "install_mockery", + "mock_packages", "mock_archive", "mock_fetch", "config", "install_mockery" ) def test_install_invalid_spec(invalid_spec): # Make sure that invalid specs raise a SpackError @@ -378,7 +364,6 @@ def test_install_invalid_spec(invalid_spec): ], ) def test_install_from_file(spec, concretize, error_code, tmpdir): - if concretize: spec.concretize() @@ -508,7 +493,6 @@ def test_junit_output_with_errors( ], ) def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir): - args = clispecs for spec in filespecs: @@ -556,10 +540,7 @@ def test_cdash_report_concretization_error( assert "<UpdateReturnStatus>" in content # The message is different based on using the # new or the old concretizer - expected_messages = ( - "Conflicts in concretized spec", - "conflicts with", - ) + expected_messages = ("Conflicts in concretized spec", "conflicts with") assert any(x in content for x in expected_messages) @@ -650,7 +631,6 @@ def test_cdash_install_from_spec_json( # capfd interferes with Spack's capturing with capfd.disabled(): with tmpdir.as_cwd(): - spec_json_path = str(tmpdir.join("spec.json")) pkg_spec = Spec("a") diff --git a/lib/spack/spack/test/cmd/maintainers.py b/lib/spack/spack/test/cmd/maintainers.py index e3452a5667..93b75da167 100644 --- a/lib/spack/spack/test/cmd/maintainers.py +++ b/lib/spack/spack/test/cmd/maintainers.py @@ -66,11 +66,7 @@ def test_all(mock_packages, capfd): with capfd.disabled(): out = split(maintainers("--all", "maintainers-1")) - assert out == [ - "maintainers-1:", - "user1,", - "user2", - ] + assert out == ["maintainers-1:", "user1,", "user2"] def test_all_by_user(mock_packages, capfd): diff --git a/lib/spack/spack/test/cmd/mirror.py b/lib/spack/spack/test/cmd/mirror.py index a6f8830734..8c355e8f50 100644 --- a/lib/spack/spack/test/cmd/mirror.py +++ b/lib/spack/spack/test/cmd/mirror.py @@ -159,13 +159,7 @@ def test_mirror_crud(mutable_config, capsys): assert "Removed mirror" in output # Test S3 connection info token - mirror( - "add", - "--s3-access-token", - "aaaaaazzzzz", - "mirror", - "s3://spack-public", - ) + mirror("add", "--s3-access-token", "aaaaaazzzzz", "mirror", "s3://spack-public") output = mirror("remove", "mirror") assert "Removed mirror" in output @@ -334,12 +328,7 @@ class TestMirrorCreate(object): specs = spack.cmd.mirror.concrete_specs_from_user(MockMirrorArgs(**cli_args)) assert not any(s.satisfies(y) for s in specs for y in not_expected) - @pytest.mark.parametrize( - "abstract_specs", - [ - ("bowtie", "callpath"), - ], - ) + @pytest.mark.parametrize("abstract_specs", [("bowtie", "callpath")]) def test_specs_from_cli_are_the_same_as_from_file(self, abstract_specs, config, tmpdir): args = MockMirrorArgs(specs=" ".join(abstract_specs)) specs_from_cli = spack.cmd.mirror.concrete_specs_from_user(args) @@ -353,12 +342,7 @@ class TestMirrorCreate(object): @pytest.mark.parametrize( "input_specs,nversions", - [ - ("callpath", 1), - ("mpich", 4), - ("callpath mpich", 3), - ("callpath mpich", "all"), - ], + [("callpath", 1), ("mpich", 4), ("callpath mpich", 3), ("callpath mpich", "all")], ) def test_versions_per_spec_produces_concrete_specs(self, input_specs, nversions, config): args = MockMirrorArgs(specs=input_specs, versions_per_spec=nversions) diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py index b76d0494df..ed36d711f8 100644 --- a/lib/spack/spack/test/cmd/test.py +++ b/lib/spack/spack/test/cmd/test.py @@ -33,7 +33,6 @@ def test_test_package_not_installed( install_mockery_mutable_config, mock_test_stage, ): - output = spack_test("run", "libdwarf") assert "No installed packages match spec libdwarf" in output diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py index 30de8a8e40..0c5660efca 100644 --- a/lib/spack/spack/test/compilers/basics.py +++ b/lib/spack/spack/test/compilers/basics.py @@ -715,19 +715,12 @@ fi # Add compiler to config compiler_info = { "spec": "gcc@foo", - "paths": { - "cc": gcc, - "cxx": None, - "f77": None, - "fc": None, - }, + "paths": {"cc": gcc, "cxx": None, "f77": None, "fc": None}, "flags": {}, "operating_system": "fake", "target": "fake", "modules": ["turn_on"], - "environment": { - "set": {"CMP_VER": test_version}, - }, + "environment": {"set": {"CMP_VER": test_version}}, "extra_rpaths": [], } compiler_dict = {"compiler": compiler_info} @@ -768,19 +761,12 @@ fi # Add compiler to config compiler_info = { "spec": "gcc@foo", - "paths": { - "cc": gcc, - "cxx": None, - "f77": None, - "fc": None, - }, + "paths": {"cc": gcc, "cxx": None, "f77": None, "fc": None}, "flags": {}, "operating_system": "fake", "target": "fake", "modules": ["turn_on"], - "environment": { - "set": {"CMP_VER": test_version}, - }, + "environment": {"set": {"CMP_VER": test_version}}, "extra_rpaths": [], } compiler_dict = {"compiler": compiler_info} @@ -829,12 +815,7 @@ echo "4.4.4" # Add compiler to config compiler_info = { "spec": "gcc@foo", - "paths": { - "cc": gcc, - "cxx": None, - "f77": None, - "fc": None, - }, + "paths": {"cc": gcc, "cxx": None, "f77": None, "fc": None}, "flags": {}, "operating_system": "fake", "target": "fake", diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 3e816dc63e..bd54b57dc4 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -407,13 +407,7 @@ class TestConcretize(object): s = Spec("singlevalue-variant-dependent-type") s.concretize() - @pytest.mark.parametrize( - "spec,version", - [ - ("dealii", "develop"), - ("xsdk", "0.4.0"), - ], - ) + @pytest.mark.parametrize("spec,version", [("dealii", "develop"), ("xsdk", "0.4.0")]) def concretize_difficult_packages(self, a, b): """Test a couple of large packages that are often broken due to current limitations in the concretizer""" @@ -582,7 +576,6 @@ class TestConcretize(object): assert "c" == find_spec(s["b"], lambda s: "+foo" in s).name def test_find_spec_sibling(self): - s = Spec.from_literal({"a": {"b +foo": {"c": None, "d": None}, "e +foo": None}}) assert "e" == find_spec(s["b"], lambda s: "+foo" in s).name @@ -710,7 +703,6 @@ class TestConcretize(object): ], ) def test_simultaneous_concretization_of_specs(self, abstract_specs): - abstract_specs = [Spec(x) for x in abstract_specs] concrete_specs = spack.concretize.concretize_specs_together(*abstract_specs) @@ -918,9 +910,7 @@ class TestConcretize(object): pytest.xfail("Known failure of the original concretizer") packages_yaml = { - "all": { - "compiler": ["clang", "gcc"], - }, + "all": {"compiler": ["clang", "gcc"]}, "cmake": { "externals": [{"spec": "cmake@3.4.3", "prefix": "/usr"}], "buildable": False, @@ -1976,9 +1966,7 @@ class TestConcretize(object): "buildable": False, "externals": [{"spec": "py-extension1@2.0", "prefix": fake_path}], }, - "python": { - "externals": [{"spec": python_spec, "prefix": fake_path}], - }, + "python": {"externals": [{"spec": python_spec, "prefix": fake_path}]}, } spack.config.set("packages", external_conf) diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py index e1084811e0..2a5ccd1f96 100644 --- a/lib/spack/spack/test/concretize_preferences.py +++ b/lib/spack/spack/test/concretize_preferences.py @@ -277,6 +277,7 @@ mpich: The specific code for parsing the module is tested elsewhere. This just tests that the preference is accounted for""" + # make sure this doesn't give us an external first. def mock_module(cmd, module): return "prepend-path PATH /dummy/path" diff --git a/lib/spack/spack/test/concretize_requirements.py b/lib/spack/spack/test/concretize_requirements.py index c7b3a3f4fd..965d85e93d 100644 --- a/lib/spack/spack/test/concretize_requirements.py +++ b/lib/spack/spack/test/concretize_requirements.py @@ -75,7 +75,7 @@ repo: ) packages_dir = tmpdir.join("packages") - for (pkg_name, pkg_str) in [_pkgx, _pkgy, _pkgv]: + for pkg_name, pkg_str in [_pkgx, _pkgy, _pkgv]: pkg_dir = packages_dir.ensure(pkg_name, dir=True) pkg_file = pkg_dir.join("package.py") with open(str(pkg_file), "w") as f: @@ -372,11 +372,7 @@ packages: @pytest.mark.parametrize( "mpi_requirement,specific_requirement", - [ - ("mpich", "@3.0.3"), - ("mpich2", "%clang"), - ("zmpi", "%gcc"), - ], + [("mpich", "@3.0.3"), ("mpich2", "%clang"), ("zmpi", "%gcc")], ) def test_requirements_on_virtual_and_on_package( mpi_requirement, specific_requirement, concretize_scope, mock_packages diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index 1c798f2abc..3ff5a52728 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -145,10 +145,7 @@ a_comps = { { "compiler": { "paths": {"cc": "/gcc422", "cxx": "/g++422", "f77": "gfortran", "fc": "gfortran"}, - "flags": { - "cppflags": "-O0 -fpic", - "fflags": "-f77", - }, + "flags": {"cppflags": "-O0 -fpic", "fflags": "-f77"}, "modules": None, "spec": "gcc@4.2.2", "operating_system": "CNL10", @@ -191,10 +188,7 @@ b_comps = { { "compiler": { "paths": {"cc": "/icc123", "cxx": "/icp123", "f77": "ifort", "fc": "ifort"}, - "flags": { - "cppflags": "-O3", - "fflags": "-f77rtl", - }, + "flags": {"cppflags": "-O3", "fflags": "-f77rtl"}, "modules": None, "spec": "icc@12.3", "operating_system": "CNL10", @@ -298,7 +292,6 @@ def test_add_config_path_with_enumerated_type(mutable_config): def test_add_config_filename(mock_low_high_config, tmpdir): - config_yaml = tmpdir.join("config-filename.yaml") config_yaml.ensure() with config_yaml.open("w") as f: @@ -586,21 +579,9 @@ def test_read_config_override_list(mock_low_high_config, write_config_file): def test_ordereddict_merge_order(): """ "Test that source keys come before dest keys in merge_yaml results.""" - source = syaml.syaml_dict( - [ - ("k1", "v1"), - ("k2", "v2"), - ("k3", "v3"), - ] - ) + source = syaml.syaml_dict([("k1", "v1"), ("k2", "v2"), ("k3", "v3")]) - dest = syaml.syaml_dict( - [ - ("k4", "v4"), - ("k3", "WRONG"), - ("k5", "v5"), - ] - ) + dest = syaml.syaml_dict([("k4", "v4"), ("k3", "WRONG"), ("k5", "v5")]) result = spack.config.merge_yaml(dest, source) assert "WRONG" not in result.values() @@ -657,11 +638,7 @@ def test_mark_internal(): "int": 6, "numbers": [1, 2, 3], "string": "foo", - "dict": { - "more_numbers": [1, 2, 3], - "another_string": "foo", - "another_int": 7, - }, + "dict": {"more_numbers": [1, 2, 3], "another_string": "foo", "another_int": 7}, } } @@ -700,13 +677,7 @@ def test_internal_config_from_data(): # add an internal config initialized from an inline dict config.push_scope( spack.config.InternalConfigScope( - "_builtin", - { - "config": { - "verify_ssl": False, - "build_jobs": 6, - } - }, + "_builtin", {"config": {"verify_ssl": False, "build_jobs": 6}} ) ) @@ -719,13 +690,7 @@ def test_internal_config_from_data(): # push one on top and see what happens. config.push_scope( spack.config.InternalConfigScope( - "higher", - { - "config": { - "checksum": True, - "verify_ssl": True, - } - }, + "higher", {"config": {"checksum": True, "verify_ssl": True}} ) ) @@ -1336,13 +1301,7 @@ def test_config_collect_urls(mutable_empty_config, mock_spider_configs, url, isf ], ) def test_config_fetch_remote_configs( - tmpdir, - mutable_empty_config, - mock_collect_urls, - mock_curl_configs, - url, - isfile, - fail, + tmpdir, mutable_empty_config, mock_collect_urls, mock_curl_configs, url, isfile, fail ): def _has_content(filename): # The first element of all configuration files for this test happen to @@ -1399,10 +1358,7 @@ def mock_collect_urls(mock_config_data, monkeypatch): @pytest.mark.parametrize( "url,skip", - [ - (github_url.format("tree"), True), - ("{0}/compilers.yaml".format(gitlab_url), True), - ], + [(github_url.format("tree"), True), ("{0}/compilers.yaml".format(gitlab_url), True)], ) def test_config_fetch_remote_configs_skip( tmpdir, mutable_empty_config, mock_collect_urls, mock_curl_configs, url, skip diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index bf6e4e6b35..9a7b3a6a9a 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -716,9 +716,7 @@ def configuration_dir(tmpdir_factory, linux_os): def _create_mock_configuration_scopes(configuration_dir): """Create the configuration scopes used in `config` and `mutable_config`.""" - scopes = [ - spack.config.InternalConfigScope("_builtin", spack.config.config_defaults), - ] + scopes = [spack.config.InternalConfigScope("_builtin", spack.config.config_defaults)] scopes += [ spack.config.ConfigScope(name, str(configuration_dir.join(name))) for name in ["site", "system", "user"] @@ -1277,12 +1275,7 @@ def mock_cvs_repository(tmpdir_factory): return format_date(timestamp) checks = { - "default": Bunch( - file=r1_file, - branch=None, - date=None, - args={"cvs": url}, - ), + "default": Bunch(file=r1_file, branch=None, date=None, args={"cvs": url}), "branch": Bunch( file=r1_file, branch="mock-branch", @@ -1298,11 +1291,7 @@ def mock_cvs_repository(tmpdir_factory): } test = Bunch( - checks=checks, - url=url, - get_branch=get_branch, - get_date=get_date, - path=str(repodir), + checks=checks, url=url, get_branch=get_branch, get_date=get_date, path=str(repodir) ) yield test @@ -1402,12 +1391,7 @@ def mock_git_repository(git, tmpdir_factory): git("tag", tag) try: - default_branch = git( - "config", - "--get", - "init.defaultBranch", - output=str, - ).strip() + default_branch = git("config", "--get", "init.defaultBranch", output=str).strip() except Exception: default_branch = "master" git("checkout", default_branch) diff --git a/lib/spack/spack/test/cray_manifest.py b/lib/spack/spack/test/cray_manifest.py index 0815116eda..4ffff0b926 100644 --- a/lib/spack/spack/test/cray_manifest.py +++ b/lib/spack/spack/test/cray_manifest.py @@ -130,10 +130,7 @@ class JsonCompilerEntry(object): """The compiler spec only lists the name/version, not arch/executables. """ - return { - "name": self.name, - "version": self.version, - } + return {"name": self.name, "version": self.version} _common_arch = JsonArchEntry(platform="linux", os="centos8", target="haswell").to_dict() @@ -265,10 +262,7 @@ def test_translate_compiler_name(): nvidia_compiler = JsonCompilerEntry( name="nvidia", version="19.1", - executables={ - "cc": "/path/to/compiler/nvc", - "cxx": "/path/to/compiler/nvc++", - }, + executables={"cc": "/path/to/compiler/nvc", "cxx": "/path/to/compiler/nvc++"}, ) compiler = compiler_from_entry(nvidia_compiler.compiler_json()) diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py index ade7303f01..323c081e64 100644 --- a/lib/spack/spack/test/directory_layout.py +++ b/lib/spack/spack/test/directory_layout.py @@ -13,10 +13,7 @@ import pytest import spack.paths import spack.repo -from spack.directory_layout import ( - DirectoryLayout, - InvalidDirectoryLayoutParametersError, -) +from spack.directory_layout import DirectoryLayout, InvalidDirectoryLayoutParametersError from spack.spec import Spec from spack.util.path import path_to_os_path diff --git a/lib/spack/spack/test/environment.py b/lib/spack/spack/test/environment.py index db59e71fea..2f363dfdca 100644 --- a/lib/spack/spack/test/environment.py +++ b/lib/spack/spack/test/environment.py @@ -9,10 +9,7 @@ import pickle import pytest from spack.environment import Environment -from spack.environment.environment import ( - SpackEnvironmentViewError, - _error_on_nonempty_view_dir, -) +from spack.environment.environment import SpackEnvironmentViewError, _error_on_nonempty_view_dir def test_environment_pickle(tmpdir): diff --git a/lib/spack/spack/test/environment_modifications.py b/lib/spack/spack/test/environment_modifications.py index 10cb5e5f8c..42ce72ad67 100644 --- a/lib/spack/spack/test/environment_modifications.py +++ b/lib/spack/spack/test/environment_modifications.py @@ -362,7 +362,6 @@ def test_preserve_environment(prepare_environment_for_tests): ) @pytest.mark.usefixtures("prepare_environment_for_tests") def test_environment_from_sourcing_files(files, expected, deleted): - env = environment.environment_after_sourcing_files(*files) # Test that variables that have been modified are still there and contain @@ -393,7 +392,6 @@ def test_clear(env): ], ) def test_sanitize_literals(env, exclude, include): - after = environment.sanitize(env, exclude, include) # Check that all the included variables are there @@ -430,7 +428,6 @@ def test_sanitize_literals(env, exclude, include): ], ) def test_sanitize_regex(env, exclude, include, expected, deleted): - after = environment.sanitize(env, exclude, include) assert all(x in after for x in expected) @@ -481,15 +478,11 @@ def test_sanitize_regex(env, exclude, include, expected, deleted): ( {"FOO": "foo", "BAR": "bar"}, {"FOO": "baz", "BAR": "baz"}, - [ - environment.SetEnv("FOO", "baz"), - environment.SetEnv("BAR", "baz"), - ], + [environment.SetEnv("FOO", "baz"), environment.SetEnv("BAR", "baz")], ), ], ) def test_from_environment_diff(before, after, search_list): - mod = environment.EnvironmentModifications.from_environment_diff(before, after) for item in search_list: diff --git a/lib/spack/spack/test/git_fetch.py b/lib/spack/spack/test/git_fetch.py index 988742153a..bf647da55e 100644 --- a/lib/spack/spack/test/git_fetch.py +++ b/lib/spack/spack/test/git_fetch.py @@ -177,7 +177,6 @@ def test_fetch_pkg_attr_submodule_init( def test_adhoc_version_submodules( mock_git_repository, config, mutable_mock_repo, monkeypatch, mock_stage ): - t = mock_git_repository.checks["tag"] # Construct the package under test pkg_class = spack.repo.path.get_pkg_class("git-test") diff --git a/lib/spack/spack/test/hooks/absolutify_elf_sonames.py b/lib/spack/spack/test/hooks/absolutify_elf_sonames.py index c3e4da31cc..b2f4a63364 100644 --- a/lib/spack/spack/test/hooks/absolutify_elf_sonames.py +++ b/lib/spack/spack/test/hooks/absolutify_elf_sonames.py @@ -11,10 +11,7 @@ import pytest import llnl.util.filesystem as fs import spack.platforms -from spack.hooks.absolutify_elf_sonames import ( - SharedLibrariesVisitor, - find_and_patch_sonames, -) +from spack.hooks.absolutify_elf_sonames import SharedLibrariesVisitor, find_and_patch_sonames from spack.util.executable import Executable diff --git a/lib/spack/spack/test/llnl/util/file_list.py b/lib/spack/spack/test/llnl/util/file_list.py index 7e85b78044..bbf9a161df 100644 --- a/lib/spack/spack/test/llnl/util/file_list.py +++ b/lib/spack/spack/test/llnl/util/file_list.py @@ -9,13 +9,7 @@ import sys import pytest -from llnl.util.filesystem import ( - HeaderList, - LibraryList, - find, - find_headers, - find_libraries, -) +from llnl.util.filesystem import HeaderList, LibraryList, find, find_headers, find_libraries import spack.paths @@ -80,7 +74,6 @@ class TestLibraryList(object): assert library_list == x def test_joined_and_str(self, library_list): - s1 = library_list.joined() expected = " ".join( [ @@ -109,7 +102,6 @@ class TestLibraryList(object): assert s3 == expected def test_flags(self, library_list): - search_flags = library_list.search_flags assert "-L/dir1" in search_flags assert "-L/dir2" in search_flags @@ -306,7 +298,6 @@ def test_library_type_search(lib_list, kwargs): ], ) def test_searching_order(search_fn, search_list, root, kwargs): - # Test search result = search_fn(search_list, root, **kwargs) diff --git a/lib/spack/spack/test/llnl/util/filesystem.py b/lib/spack/spack/test/llnl/util/filesystem.py index 86c9f91c48..bbadfcbca9 100644 --- a/lib/spack/spack/test/llnl/util/filesystem.py +++ b/lib/spack/spack/test/llnl/util/filesystem.py @@ -315,7 +315,6 @@ def test_paths_containing_libs(dirs_with_libfiles): def test_move_transaction_commit(tmpdir): - fake_library = tmpdir.mkdir("lib").join("libfoo.so") fake_library.write("Just some fake content.") @@ -330,7 +329,6 @@ def test_move_transaction_commit(tmpdir): def test_move_transaction_rollback(tmpdir): - fake_library = tmpdir.mkdir("lib").join("libfoo.so") fake_library.write("Initial content.") @@ -812,28 +810,10 @@ def test_visit_directory_tree_follow_all(noncyclical_dir_structure): j("c", "file_2"), j("file_3"), ] - assert visitor.dirs_before == [ - j("a"), - j("a", "d"), - j("b", "d"), - j("c"), - ] - assert visitor.dirs_after == [ - j("a", "d"), - j("a"), - j("b", "d"), - j("c"), - ] - assert visitor.symlinked_dirs_before == [ - j("a", "to_c"), - j("b"), - j("b", "to_c"), - ] - assert visitor.symlinked_dirs_after == [ - j("a", "to_c"), - j("b", "to_c"), - j("b"), - ] + assert visitor.dirs_before == [j("a"), j("a", "d"), j("b", "d"), j("c")] + assert visitor.dirs_after == [j("a", "d"), j("a"), j("b", "d"), j("c")] + assert visitor.symlinked_dirs_before == [j("a", "to_c"), j("b"), j("b", "to_c")] + assert visitor.symlinked_dirs_after == [j("a", "to_c"), j("b", "to_c"), j("b")] @pytest.mark.skipif(sys.platform == "win32", reason="Requires symlinks") @@ -849,20 +829,9 @@ def test_visit_directory_tree_follow_dirs(noncyclical_dir_structure): j("c", "file_2"), j("file_3"), ] - assert visitor.dirs_before == [ - j("a"), - j("a", "d"), - j("c"), - ] - assert visitor.dirs_after == [ - j("a", "d"), - j("a"), - j("c"), - ] - assert visitor.symlinked_dirs_before == [ - j("a", "to_c"), - j("b"), - ] + assert visitor.dirs_before == [j("a"), j("a", "d"), j("c")] + assert visitor.dirs_after == [j("a", "d"), j("a"), j("c")] + assert visitor.symlinked_dirs_before == [j("a", "to_c"), j("b")] assert not visitor.symlinked_dirs_after @@ -872,17 +841,10 @@ def test_visit_directory_tree_follow_none(noncyclical_dir_structure): visitor = RegisterVisitor(root, follow_dirs=False, follow_symlink_dirs=False) fs.visit_directory_tree(root, visitor) j = os.path.join - assert visitor.files == [ - j("file_3"), - ] - assert visitor.dirs_before == [ - j("a"), - j("c"), - ] + assert visitor.files == [j("file_3")] + assert visitor.dirs_before == [j("a"), j("c")] assert not visitor.dirs_after - assert visitor.symlinked_dirs_before == [ - j("b"), - ] + assert visitor.symlinked_dirs_before == [j("b")] assert not visitor.symlinked_dirs_after diff --git a/lib/spack/spack/test/llnl/util/lang.py b/lib/spack/spack/test/llnl/util/lang.py index 95cc327dcc..d913ecc264 100644 --- a/lib/spack/spack/test/llnl/util/lang.py +++ b/lib/spack/spack/test/llnl/util/lang.py @@ -239,21 +239,14 @@ def test_unequal_args(args1, kwargs1, args2, kwargs2): "args1,kwargs1,args2,kwargs2", [ # Ensure that kwargs are stably sorted. - ((), {"a": 3, "b": 4}, (), {"b": 4, "a": 3}), + ((), {"a": 3, "b": 4}, (), {"b": 4, "a": 3}) ], ) def test_equal_args(args1, kwargs1, args2, kwargs2): assert stable_args(*args1, **kwargs1) == stable_args(*args2, **kwargs2) -@pytest.mark.parametrize( - "args, kwargs", - [ - ((1,), {}), - ((), {"a": 3}), - ((1,), {"a": 3}), - ], -) +@pytest.mark.parametrize("args, kwargs", [((1,), {}), ((), {"a": 3}), ((1,), {"a": 3})]) def test_memoized(args, kwargs): @memoized def f(*args, **kwargs): @@ -265,10 +258,7 @@ def test_memoized(args, kwargs): assert f.cache[key] == "return-value" -@pytest.mark.parametrize( - "args, kwargs", - [(([1],), {}), ((), {"a": [1]})], -) +@pytest.mark.parametrize("args, kwargs", [(([1],), {}), ((), {"a": [1]})]) def test_memoized_unhashable(args, kwargs): """Check that an exception is raised clearly""" diff --git a/lib/spack/spack/test/llnl/util/link_tree.py b/lib/spack/spack/test/llnl/util/link_tree.py index 391e060537..3ae39bbb79 100644 --- a/lib/spack/spack/test/llnl/util/link_tree.py +++ b/lib/spack/spack/test/llnl/util/link_tree.py @@ -103,7 +103,6 @@ def test_merge_to_new_directory_relative(stage, link_tree): def test_merge_to_existing_directory(stage, link_tree): with working_dir(stage.path): - touchp("dest/x") touchp("dest/a/b/y") diff --git a/lib/spack/spack/test/llnl/util/tty/log.py b/lib/spack/spack/test/llnl/util/tty/log.py index 9b37912d3d..b5767d1862 100644 --- a/lib/spack/spack/test/llnl/util/tty/log.py +++ b/lib/spack/spack/test/llnl/util/tty/log.py @@ -450,10 +450,7 @@ def mock_shell_v_v_no_termios(proc, ctl, **kwargs): @pytest.mark.skipif(not termios, reason="requires termios support") @pytest.mark.parametrize( "test_fn,termios_on_or_off", - [ - (mock_shell_v_v, lang.nullcontext), - (mock_shell_v_v_no_termios, no_termios), - ], + [(mock_shell_v_v, lang.nullcontext), (mock_shell_v_v_no_termios, no_termios)], ) @pytest.mark.xfail(reason="Fails almost consistently when run with coverage and xdist") def test_foreground_background_output(test_fn, capfd, termios_on_or_off, tmpdir): diff --git a/lib/spack/spack/test/mirror.py b/lib/spack/spack/test/mirror.py index cd5a7da7fe..8fa32c4893 100644 --- a/lib/spack/spack/test/mirror.py +++ b/lib/spack/spack/test/mirror.py @@ -123,7 +123,6 @@ def test_hg_mirror(mock_hg_repository): def test_all_mirror(mock_git_repository, mock_svn_repository, mock_hg_repository, mock_archive): - set_up_package("git-test", mock_git_repository, "git") set_up_package("svn-test", mock_svn_repository, "svn") set_up_package("hg-test", mock_hg_repository, "hg") @@ -133,13 +132,7 @@ def test_all_mirror(mock_git_repository, mock_svn_repository, mock_hg_repository @pytest.mark.parametrize( - "mirror", - [ - spack.mirror.Mirror( - "https://example.com/fetch", - "https://example.com/push", - ), - ], + "mirror", [spack.mirror.Mirror("https://example.com/fetch", "https://example.com/push")] ) def test_roundtrip_mirror(mirror): mirror_yaml = mirror.to_yaml() @@ -174,11 +167,10 @@ def test_invalid_json_mirror(invalid_json, error_message): spack.mirror.MirrorCollection( mirrors={ "example-mirror": spack.mirror.Mirror( - "https://example.com/fetch", - "https://example.com/push", - ).to_dict(), - }, - ), + "https://example.com/fetch", "https://example.com/push" + ).to_dict() + } + ) ], ) def test_roundtrip_mirror_collection(mirror_collection): diff --git a/lib/spack/spack/test/modules/common.py b/lib/spack/spack/test/modules/common.py index 53b5b71ad3..691a50dd54 100644 --- a/lib/spack/spack/test/modules/common.py +++ b/lib/spack/spack/test/modules/common.py @@ -22,14 +22,7 @@ pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="does not run on def test_update_dictionary_extending_list(): target = {"foo": {"a": 1, "b": 2, "d": 4}, "bar": [1, 2, 4], "baz": "foobar"} - update = { - "foo": { - "c": 3, - }, - "bar": [3], - "baz": "foobaz", - "newkey": {"d": 4}, - } + update = {"foo": {"c": 3}, "bar": [3], "baz": "foobaz", "newkey": {"d": 4}} spack.modules.common.update_dictionary_extending_lists(target, update) assert len(target) == 4 assert len(target["foo"]) == 4 diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py index fbd8be49a7..9ca0c3aa50 100644 --- a/lib/spack/spack/test/modules/lmod.py +++ b/lib/spack/spack/test/modules/lmod.py @@ -41,10 +41,7 @@ def provider(request): return request.param -@pytest.mark.usefixtures( - "config", - "mock_packages", -) +@pytest.mark.usefixtures("config", "mock_packages") class TestLmod(object): def test_file_layout(self, compiler, provider, factory, module_configuration): """Tests the layout of files in the hierarchy is the one expected.""" @@ -254,12 +251,7 @@ class TestLmod(object): assert writer.conf.core_compilers @pytest.mark.parametrize( - "spec_str", - [ - "mpileaks target=nocona", - "mpileaks target=core2", - "mpileaks target=x86_64", - ], + "spec_str", ["mpileaks target=nocona", "mpileaks target=core2", "mpileaks target=x86_64"] ) @pytest.mark.regression("13005") def test_only_generic_microarchitectures_in_root( diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index 2ea9f1ccd6..145e5e6156 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -218,7 +218,6 @@ class TestTcl(object): modulefile_content("mpileaks") def test_module_index(self, module_configuration, factory, tmpdir_factory): - module_configuration("suffix") w1, s1 = factory("mpileaks") diff --git a/lib/spack/spack/test/package_class.py b/lib/spack/spack/test/package_class.py index fff839932f..6f5d650231 100644 --- a/lib/spack/spack/test/package_class.py +++ b/lib/spack/spack/test/package_class.py @@ -61,11 +61,7 @@ def test_possible_dependencies(mock_packages, mpileaks_possible_deps): def test_possible_direct_dependencies(mock_packages, mpileaks_possible_deps): pkg_cls = spack.repo.path.get_pkg_class("mpileaks") deps = pkg_cls.possible_dependencies(transitive=False, expand_virtuals=False) - assert { - "callpath": set(), - "mpi": set(), - "mpileaks": {"callpath", "mpi"}, - } == deps + assert {"callpath": set(), "mpi": set(), "mpileaks": {"callpath", "mpi"}} == deps def test_possible_dependencies_virtual(mock_packages, mpi_names): @@ -101,10 +97,9 @@ def test_possible_dependencies_with_deptypes(mock_packages): "dtlink2": set(), } == dtbuild1.possible_dependencies(deptype=("build")) - assert { - "dtbuild1": {"dtlink2"}, - "dtlink2": set(), - } == dtbuild1.possible_dependencies(deptype=("link")) + assert {"dtbuild1": {"dtlink2"}, "dtlink2": set()} == dtbuild1.possible_dependencies( + deptype=("link") + ) def test_possible_dependencies_with_multiple_classes(mock_packages, mpileaks_possible_deps): diff --git a/lib/spack/spack/test/packaging.py b/lib/spack/spack/test/packaging.py index 16a5753e60..75891ce94c 100644 --- a/lib/spack/spack/test/packaging.py +++ b/lib/spack/spack/test/packaging.py @@ -252,7 +252,6 @@ def test_relocate_links(tmpdir): def test_needs_relocation(): - assert needs_binary_relocation("application", "x-sharedlib") assert needs_binary_relocation("application", "x-executable") assert not needs_binary_relocation("application", "x-octet-stream") diff --git a/lib/spack/spack/test/pattern.py b/lib/spack/spack/test/pattern.py index 7d89a87f50..ccf43c96f1 100644 --- a/lib/spack/spack/test/pattern.py +++ b/lib/spack/spack/test/pattern.py @@ -67,7 +67,6 @@ def composite(interface, implementation, request): def test_composite_interface_calls(interface, composite): - composite.add() assert interface.counter == 3 @@ -77,7 +76,6 @@ def test_composite_interface_calls(interface, composite): def test_composite_wrong_container(interface): - with pytest.raises(TypeError): @pattern.composite(interface=interface, container=2) @@ -86,7 +84,6 @@ def test_composite_wrong_container(interface): def test_composite_no_methods(): - with pytest.raises(TypeError): @pattern.composite() diff --git a/lib/spack/spack/test/relocate_text.py b/lib/spack/spack/test/relocate_text.py index 9f97e7e83f..a92497ce16 100644 --- a/lib/spack/spack/test/relocate_text.py +++ b/lib/spack/spack/test/relocate_text.py @@ -152,9 +152,7 @@ def test_ordered_replacement(): # Too short matching suffix, identical string length error_msg = "Cannot replace {!r} with {!r} in the C-string {!r}.".format( - b"pkg-gwixwaxlgczp6", - b"pkg-zkesfrzlgczp6", - b"pkg-gwixwaxlgczp6", + b"pkg-gwixwaxlgczp6", b"pkg-zkesfrzlgczp6", b"pkg-gwixwaxlgczp6" ) with pytest.raises(relocate_text.CannotShrinkCString, match=error_msg): replace_and_expect( @@ -169,9 +167,7 @@ def test_ordered_replacement(): # at a distance where we cant keep a long enough suffix, and one where we can, # so we should expect failure when the first null is used. error_msg = "Cannot replace {!r} with {!r} in the C-string {!r}.".format( - b"pkg-abcdef", - b"pkg-xyzabc", - b"pkg-abcdef", + b"pkg-abcdef", b"pkg-xyzabc", b"pkg-abcdef" ) with pytest.raises(relocate_text.CannotShrinkCString, match=error_msg): replace_and_expect( @@ -231,11 +227,7 @@ def test_inplace_text_replacement(): b"Install path: /replacement.", ) - replace_and_expect( - [(b"/my/prefix", b"/replacement")], - b"#!/my/prefix", - b"#!/replacement", - ) + replace_and_expect([(b"/my/prefix", b"/replacement")], b"#!/my/prefix", b"#!/replacement") def test_relocate_text_filters_redundant_entries(): diff --git a/lib/spack/spack/test/schema.py b/lib/spack/spack/test/schema.py index c096b9461c..d7f4e524ff 100644 --- a/lib/spack/spack/test/schema.py +++ b/lib/spack/spack/test/schema.py @@ -35,11 +35,7 @@ def module_suffixes_schema(): "properties": { "suffixes": { "validate_spec": True, - "patternProperties": { - r"\w[\w-]*": { - "type": "string", - } - }, + "patternProperties": {r"\w[\w-]*": {"type": "string"}}, } }, } diff --git a/lib/spack/spack/test/spack_yaml.py b/lib/spack/spack/test/spack_yaml.py index a6d7e34438..de5e6814d9 100644 --- a/lib/spack/spack/test/spack_yaml.py +++ b/lib/spack/spack/test/spack_yaml.py @@ -31,7 +31,6 @@ config_file: def test_parse(data): - expected = { "config_file": syaml.syaml_dict( [ @@ -52,7 +51,6 @@ def test_parse(data): def test_dict_order(data): - expected_order = ["x86_64", "some_list", "another_list", "some_key"] assert list(data["config_file"].keys()) == expected_order diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py index 5afc831096..5c437da6ba 100644 --- a/lib/spack/spack/test/spec_dag.py +++ b/lib/spack/spack/test/spec_dag.py @@ -342,9 +342,7 @@ class TestSpecDag(object): spec.normalize() spec.normalize() - def test_normalize_with_virtual_spec( - self, - ): + def test_normalize_with_virtual_spec(self): dag = Spec.from_literal( { "mpileaks": { @@ -484,7 +482,7 @@ class TestSpecDag(object): mpich: None, }, mpich: None, - }, + } } ) @@ -826,7 +824,6 @@ class TestSpecDag(object): ].deptypes == ("build", "link", "run") def check_diamond_normalized_dag(self, spec): - dag = Spec.from_literal( { "dt-diamond": { diff --git a/lib/spack/spack/test/spec_list.py b/lib/spack/spack/test/spec_list.py index 3595ddfd76..7df87542b0 100644 --- a/lib/spack/spack/test/spec_list.py +++ b/lib/spack/spack/test/spec_list.py @@ -23,12 +23,7 @@ class TestSpecList(object): "mpileaks", "zmpi@1.0", "mpich@3.0", - { - "matrix": [ - ["hypre"], - ["%gcc@4.5.0", "%clang@3.3"], - ] - }, + {"matrix": [["hypre"], ["%gcc@4.5.0", "%clang@3.3"]]}, "libelf", ] diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index c09ddeb920..d60df890ba 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -42,7 +42,6 @@ def _specify(spec_like): def check_satisfies(target_spec, constraint_spec, target_concrete=False): - target = make_spec(target_spec, target_concrete) constraint = _specify(constraint_spec) @@ -55,7 +54,6 @@ def check_satisfies(target_spec, constraint_spec, target_concrete=False): def check_unsatisfiable(target_spec, constraint_spec, target_concrete=False): - target = make_spec(target_spec, target_concrete) constraint = _specify(constraint_spec) @@ -325,7 +323,6 @@ class TestSpecSematics(object): assert "a@1.0" not in spec def test_unsatisfiable_multi_value_variant(self): - # Semantics for a multi-valued variant is different # Depending on whether the spec is concrete or not diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py index 56d85bfca2..62396d57ef 100644 --- a/lib/spack/spack/test/spec_syntax.py +++ b/lib/spack/spack/test/spec_syntax.py @@ -403,9 +403,7 @@ def specfile_for(default_mock_concretization): # Key value pairs with ":" and "," in the value ( r"target=:broadwell,icelake", - [ - Token(TokenType.KEY_VALUE_PAIR, value="target=:broadwell,icelake"), - ], + [Token(TokenType.KEY_VALUE_PAIR, value="target=:broadwell,icelake")], r"arch=None-None-:broadwell,icelake", ), # Hash pair version followed by a variant @@ -480,13 +478,7 @@ def specfile_for(default_mock_concretization): [Token(TokenType.VERSION, value="@1.2 : 1.4 , 1.6")], "@1.2:1.4,1.6", ), - ( - "@1.2 : develop", - [ - Token(TokenType.VERSION, value="@1.2 : develop"), - ], - "@1.2:develop", - ), + ("@1.2 : develop", [Token(TokenType.VERSION, value="@1.2 : develop")], "@1.2:develop"), ( "@1.2 : develop = foo", [ @@ -522,10 +514,7 @@ def specfile_for(default_mock_concretization): ), ( "@:0.4 % nvhpc", - [ - Token(TokenType.VERSION, value="@:0.4"), - Token(TokenType.COMPILER, value="% nvhpc"), - ], + [Token(TokenType.VERSION, value="@:0.4"), Token(TokenType.COMPILER, value="% nvhpc")], "@:0.4%nvhpc", ), ], @@ -847,39 +836,23 @@ def test_error_conditions(text, exc_cls): [ # Specfile related errors pytest.param( - "/bogus/path/libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_WINDOWS, - ), - pytest.param( - "../../libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_WINDOWS, - ), - pytest.param( - "./libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_WINDOWS, + "/bogus/path/libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_WINDOWS ), + pytest.param("../../libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_WINDOWS), + pytest.param("./libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_WINDOWS), pytest.param( "libfoo ^/bogus/path/libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_WINDOWS, ), pytest.param( - "libfoo ^../../libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_WINDOWS, + "libfoo ^../../libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_WINDOWS ), pytest.param( - "libfoo ^./libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_WINDOWS, + "libfoo ^./libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_WINDOWS ), pytest.param( - "/bogus/path/libdwarf.yamlfoobar", - spack.spec.SpecFilenameError, - marks=FAIL_ON_WINDOWS, + "/bogus/path/libdwarf.yamlfoobar", spack.spec.SpecFilenameError, marks=FAIL_ON_WINDOWS ), pytest.param( "libdwarf^/bogus/path/libelf.yamlfoobar ^/path/to/bogus.yaml", @@ -887,34 +860,20 @@ def test_error_conditions(text, exc_cls): marks=FAIL_ON_WINDOWS, ), pytest.param( - "c:\\bogus\\path\\libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_UNIX, - ), - pytest.param( - "..\\..\\libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_UNIX, - ), - pytest.param( - ".\\libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_UNIX, + "c:\\bogus\\path\\libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_UNIX ), + pytest.param("..\\..\\libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_UNIX), + pytest.param(".\\libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_UNIX), pytest.param( "libfoo ^c:\\bogus\\path\\libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_UNIX, ), pytest.param( - "libfoo ^..\\..\\libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_UNIX, + "libfoo ^..\\..\\libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_UNIX ), pytest.param( - "libfoo ^.\\libdwarf.yaml", - spack.spec.NoSuchSpecFileError, - marks=FAIL_ON_UNIX, + "libfoo ^.\\libdwarf.yaml", spack.spec.NoSuchSpecFileError, marks=FAIL_ON_UNIX ), pytest.param( "c:\\bogus\\path\\libdwarf.yamlfoobar", diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py index 48826dc493..ff614c0d68 100644 --- a/lib/spack/spack/test/spec_yaml.py +++ b/lib/spack/spack/test/spec_yaml.py @@ -252,13 +252,7 @@ def test_ordered_read_not_required_for_consistent_dag_hash(config, mock_packages assert spec.dag_hash() == round_trip_reversed_json_spec.dag_hash() -@pytest.mark.parametrize( - "module", - [ - spack.spec, - spack.version, - ], -) +@pytest.mark.parametrize("module", [spack.spec, spack.version]) def test_hashes_use_no_python_dicts(module): """Coarse check to make sure we don't use dicts in Spec.to_node_dict(). @@ -479,15 +473,7 @@ ordered_spec = collections.OrderedDict( ] ), ), - ( - "compiler", - collections.OrderedDict( - [ - ("name", "apple-clang"), - ("version", "13.0.0"), - ] - ), - ), + ("compiler", collections.OrderedDict([("name", "apple-clang"), ("version", "13.0.0")])), ("name", "zlib"), ("namespace", "builtin"), ( diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py index 06ca3732a6..1cc1f20472 100644 --- a/lib/spack/spack/test/stage.py +++ b/lib/spack/spack/test/stage.py @@ -198,6 +198,7 @@ def tmp_build_stage_dir(tmpdir, clear_stage_root): @pytest.fixture def mock_stage_archive(tmp_build_stage_dir): """Create the directories and files for the staged mock archive.""" + # Mock up a stage area that looks like this: # # tmpdir/ test_files_dir @@ -385,7 +386,6 @@ def check_stage_dir_perms(prefix, path): @pytest.mark.usefixtures("mock_packages") class TestStage(object): - stage_name = "spack-test-stage" def test_setup_and_destroy_name_with_tmp(self, mock_stage_archive): @@ -444,7 +444,6 @@ class TestStage(object): @pytest.mark.disable_clean_stage_check def test_composite_stage_with_expand_resource(self, composite_stage_with_expanding_resource): - ( composite_stage, root_stage, diff --git a/lib/spack/spack/test/test_suite.py b/lib/spack/spack/test/test_suite.py index b0e28a1474..3bebfd3da5 100644 --- a/lib/spack/spack/test/test_suite.py +++ b/lib/spack/spack/test/test_suite.py @@ -89,10 +89,7 @@ def test_test_uninstalled(mock_packages, install_mockery, mock_test_stage): @pytest.mark.parametrize( "arguments,status,msg", - [ - ({}, "SKIPPED", "Skipped"), - ({"externals": True}, "NO-TESTS", "No tests"), - ], + [({}, "SKIPPED", "Skipped"), ({"externals": True}, "NO-TESTS", "No tests")], ) def test_test_external( mock_packages, install_mockery, mock_test_stage, monkeypatch, arguments, status, msg @@ -146,7 +143,6 @@ def test_test_spec_run_once(mock_packages, install_mockery, mock_test_stage): def test_test_spec_passes(mock_packages, install_mockery, mock_test_stage, monkeypatch): - spec = spack.spec.Spec("simple-standalone-test").concretized() monkeypatch.setattr(spack.spec.Spec, "installed", _true) test_suite = spack.install_test.TestSuite([spec]) diff --git a/lib/spack/spack/test/traverse.py b/lib/spack/spack/test/traverse.py index 1334f33883..dae944ffc3 100644 --- a/lib/spack/spack/test/traverse.py +++ b/lib/spack/spack/test/traverse.py @@ -145,16 +145,7 @@ def test_breadth_first_traversal(abstract_specs_dtuse): def test_breadth_first_deptype_traversal(abstract_specs_dtuse): s = abstract_specs_dtuse["dtuse"] - names = [ - "dtuse", - "dttop", - "dtbuild1", - "dtlink1", - "dtbuild2", - "dtlink2", - "dtlink3", - "dtlink4", - ] + names = ["dtuse", "dttop", "dtbuild1", "dtlink1", "dtbuild2", "dtlink2", "dtlink3", "dtlink4"] traversal = traverse.traverse_nodes([s], order="breadth", key=id, deptype=("build", "link")) assert [x.name for x in traversal] == names @@ -243,23 +234,13 @@ def test_breadth_first_versus_depth_first_tree(abstract_specs_chain): assert [ (depth, edge.spec.name) for (depth, edge) in traverse.traverse_tree([s], cover="nodes", depth_first=False) - ] == [ - (0, "chain-a"), - (1, "chain-b"), - (1, "chain-c"), - (1, "chain-d"), - ] + ] == [(0, "chain-a"), (1, "chain-b"), (1, "chain-c"), (1, "chain-d")] # DFS will disover all nodes along the chain a -> b -> c -> d. assert [ (depth, edge.spec.name) for (depth, edge) in traverse.traverse_tree([s], cover="nodes", depth_first=True) - ] == [ - (0, "chain-a"), - (1, "chain-b"), - (2, "chain-c"), - (3, "chain-d"), - ] + ] == [(0, "chain-a"), (1, "chain-b"), (2, "chain-c"), (3, "chain-d")] # When covering all edges, we should never exceed depth 2 in BFS. assert [ @@ -402,15 +383,7 @@ def test_traverse_edges_topo(abstract_specs_toposort): # See figure above, we have 7 edges (excluding artifical ones to the root) assert set(edges) == set( - [ - ("A", "B"), - ("A", "C"), - ("B", "F"), - ("B", "G"), - ("C", "D"), - ("D", "B"), - ("E", "D"), - ] + [("A", "B"), ("A", "C"), ("B", "F"), ("B", "G"), ("C", "D"), ("D", "B"), ("E", "D")] ) # Verify that all in-edges precede all out-edges diff --git a/lib/spack/spack/test/util/elf.py b/lib/spack/spack/test/util/elf.py index aef9afeebf..b80072d015 100644 --- a/lib/spack/spack/test/util/elf.py +++ b/lib/spack/spack/test/util/elf.py @@ -29,10 +29,7 @@ def skip_unless_linux(f): @skip_unless_linux @pytest.mark.parametrize( "linker_flag,is_runpath", - [ - ("-Wl,--disable-new-dtags", False), - ("-Wl,--enable-new-dtags", True), - ], + [("-Wl,--disable-new-dtags", False), ("-Wl,--enable-new-dtags", True)], ) def test_elf_parsing_shared_linking(linker_flag, is_runpath, tmpdir): gcc = spack.util.executable.which("gcc") @@ -159,9 +156,6 @@ def test_elf_get_and_replace_rpaths(binary_with_rpaths): elf.replace_rpath_in_place_or_raise( executable, OrderedDict( - [ - (b"/short-a", b"/very/long/prefix-a"), - (b"/short-b", b"/very/long/prefix-b"), - ] + [(b"/short-a", b"/very/long/prefix-a"), (b"/short-b", b"/very/long/prefix-b")] ), ) diff --git a/lib/spack/spack/test/variant.py b/lib/spack/spack/test/variant.py index f352c43655..18daec359f 100644 --- a/lib/spack/spack/test/variant.py +++ b/lib/spack/spack/test/variant.py @@ -25,7 +25,6 @@ from spack.variant import ( class TestMultiValuedVariant(object): def test_initialization(self): - # Basic properties a = MultiValuedVariant("foo", "bar,baz") assert repr(a) == "MultiValuedVariant('foo', 'bar,baz')" @@ -70,7 +69,6 @@ class TestMultiValuedVariant(object): assert eval(repr(d)) == a def test_satisfies(self): - a = MultiValuedVariant("foo", "bar,baz") b = MultiValuedVariant("foo", "bar") c = MultiValuedVariant("fee", "bar,baz") @@ -104,7 +102,6 @@ class TestMultiValuedVariant(object): assert not d.satisfies(almost_d_bv) def test_compatible(self): - a = MultiValuedVariant("foo", "bar,baz") b = MultiValuedVariant("foo", "True") c = MultiValuedVariant("fee", "bar,baz") @@ -139,7 +136,6 @@ class TestMultiValuedVariant(object): assert not c.compatible(b_bv) def test_constrain(self): - # Try to constrain on a value with less constraints than self a = MultiValuedVariant("foo", "bar,baz") b = MultiValuedVariant("foo", "bar") @@ -189,7 +185,6 @@ class TestMultiValuedVariant(object): assert not a.constrain(d_bv) def test_yaml_entry(self): - a = MultiValuedVariant("foo", "bar,baz,barbaz") b = MultiValuedVariant("foo", "bar, baz, barbaz") expected = ("foo", sorted(["bar", "baz", "barbaz"])) @@ -205,7 +200,6 @@ class TestMultiValuedVariant(object): class TestSingleValuedVariant(object): def test_initialization(self): - # Basic properties a = SingleValuedVariant("foo", "bar") assert repr(a) == "SingleValuedVariant('foo', 'bar')" @@ -262,7 +256,6 @@ class TestSingleValuedVariant(object): assert not e.satisfies(almost_e_bv) def test_compatible(self): - a = SingleValuedVariant("foo", "bar") b = SingleValuedVariant("fee", "bar") c = SingleValuedVariant("foo", "baz") @@ -317,7 +310,6 @@ class TestSingleValuedVariant(object): assert not e.compatible(almost_e_bv) def test_constrain(self): - # Try to constrain on a value equal to self a = SingleValuedVariant("foo", "bar") b = SingleValuedVariant("foo", "bar") @@ -449,7 +441,6 @@ class TestBoolValuedVariant(object): assert d.satisfies(d_sv) def test_compatible(self): - a = BoolValuedVariant("foo", True) b = BoolValuedVariant("fee", True) c = BoolValuedVariant("foo", False) @@ -523,7 +514,6 @@ class TestBoolValuedVariant(object): assert not a.constrain(v) def test_yaml_entry(self): - a = BoolValuedVariant("foo", "True") expected = ("foo", True) assert a.yaml_entry() == expected diff --git a/lib/spack/spack/test/versions.py b/lib/spack/spack/test/versions.py index 07590e89ca..586908b791 100644 --- a/lib/spack/spack/test/versions.py +++ b/lib/spack/spack/test/versions.py @@ -16,14 +16,7 @@ from llnl.util.filesystem import working_dir import spack.package_base import spack.spec -from spack.version import ( - GitVersion, - Version, - VersionBase, - VersionList, - VersionRange, - ver, -) +from spack.version import GitVersion, Version, VersionBase, VersionList, VersionRange, ver def assert_ver_lt(a, b): diff --git a/lib/spack/spack/test/web.py b/lib/spack/spack/test/web.py index ba9b1e40f1..4cc5277cd0 100644 --- a/lib/spack/spack/test/web.py +++ b/lib/spack/spack/test/web.py @@ -224,11 +224,7 @@ def test_list_url(tmpdir): class MockPages(object): def search(self, *args, **kwargs): - return [ - {"Key": "keyone"}, - {"Key": "keytwo"}, - {"Key": "keythree"}, - ] + return [{"Key": "keyone"}, {"Key": "keytwo"}, {"Key": "keythree"}] class MockPaginator(object): diff --git a/lib/spack/spack/util/elf.py b/lib/spack/spack/util/elf.py index ef19ddd341..c5b5223512 100644 --- a/lib/spack/spack/util/elf.py +++ b/lib/spack/spack/util/elf.py @@ -46,30 +46,12 @@ SectionHeader = namedtuple( ProgramHeader32 = namedtuple( "ProgramHeader32", - [ - "p_type", - "p_offset", - "p_vaddr", - "p_paddr", - "p_filesz", - "p_memsz", - "p_flags", - "p_align", - ], + ["p_type", "p_offset", "p_vaddr", "p_paddr", "p_filesz", "p_memsz", "p_flags", "p_align"], ) ProgramHeader64 = namedtuple( "ProgramHeader64", - [ - "p_type", - "p_flags", - "p_offset", - "p_vaddr", - "p_paddr", - "p_filesz", - "p_memsz", - "p_align", - ], + ["p_type", "p_flags", "p_offset", "p_vaddr", "p_paddr", "p_filesz", "p_memsz", "p_align"], ) @@ -516,8 +498,7 @@ class ElfDynamicSectionUpdateFailed(Exception): self.new = new super(ElfDynamicSectionUpdateFailed, self).__init__( "New rpath {} is longer than old rpath {}".format( - new.decode("utf-8"), - old.decode("utf-8"), + new.decode("utf-8"), old.decode("utf-8") ) ) diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py index 1f019cbbab..c85b882253 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -1004,12 +1004,7 @@ def environment_after_sourcing_files(*files, **kwargs): # Try to source the file source_file_arguments = " ".join( - [ - source_file, - suppress_output, - concatenate_on_success, - dump_environment, - ] + [source_file, suppress_output, concatenate_on_success, dump_environment] ) output = shell(source_file_arguments, output=str, env=environment, ignore_quotes=True) return json.loads(output) diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index 35a82026ac..4e026b565c 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -196,12 +196,7 @@ class Executable(object): try: proc = subprocess.Popen( - cmd, - stdin=istream, - stderr=estream, - stdout=ostream, - env=env, - close_fds=False, + cmd, stdin=istream, stderr=estream, stdout=ostream, env=env, close_fds=False ) out, err = proc.communicate() diff --git a/lib/spack/spack/util/gcs.py b/lib/spack/spack/util/gcs.py index e1f972ff23..9feb489192 100644 --- a/lib/spack/spack/util/gcs.py +++ b/lib/spack/spack/util/gcs.py @@ -160,7 +160,6 @@ class GCSBlob(object): """ def __init__(self, url, client=None): - self.url = url if url.scheme != "gs": raise ValueError( diff --git a/lib/spack/spack/util/package_hash.py b/lib/spack/spack/util/package_hash.py index b5115f6aa6..b60a576674 100644 --- a/lib/spack/spack/util/package_hash.py +++ b/lib/spack/spack/util/package_hash.py @@ -309,10 +309,7 @@ def canonical_source(spec, filter_multimethods=True, source=None): AST if they are known statically to be unused. Supply False to disable. source (str): Optionally provide a string to read python code from. """ - return unparse( - package_ast(spec, filter_multimethods, source=source), - py_ver_consistent=True, - ) + return unparse(package_ast(spec, filter_multimethods, source=source), py_ver_consistent=True) def package_hash(spec, source=None): diff --git a/lib/spack/spack/util/spack_yaml.py b/lib/spack/spack/util/spack_yaml.py index 651713d121..84e22bee07 100644 --- a/lib/spack/spack/util/spack_yaml.py +++ b/lib/spack/spack/util/spack_yaml.py @@ -51,12 +51,7 @@ class syaml_int(int): #: mapping from syaml type -> primitive type -syaml_types = { - syaml_str: str, - syaml_int: int, - syaml_dict: dict, - syaml_list: list, -} +syaml_types = {syaml_str: str, syaml_int: int, syaml_dict: dict, syaml_list: list} markable_types = set(syaml_types) | set([yaml.comments.CommentedSeq, yaml.comments.CommentedMap]) diff --git a/lib/spack/spack/util/unparse/unparser.py b/lib/spack/spack/util/unparse/unparser.py index c24cf8ee1a..9ca8eb90a9 100644 --- a/lib/spack/spack/util/unparse/unparser.py +++ b/lib/spack/spack/util/unparse/unparser.py @@ -614,12 +614,7 @@ class Unparser: """Write string literal value w/a best effort attempt to avoid backslashes.""" string, quote_types = self._str_literal_helper(string, quote_types=quote_types) quote_type = quote_types[0] - self.write( - "{quote_type}{string}{quote_type}".format( - quote_type=quote_type, - string=string, - ) - ) + self.write("{quote_type}{string}{quote_type}".format(quote_type=quote_type, string=string)) # expr def visit_Bytes(self, node): @@ -664,12 +659,7 @@ class Unparser: new_buffer.append(value) value = "".join(new_buffer) quote_type = quote_types[0] - self.write( - "{quote_type}{value}{quote_type}".format( - quote_type=quote_type, - value=value, - ) - ) + self.write("{quote_type}{value}{quote_type}".format(quote_type=quote_type, value=value)) def visit_FormattedValue(self, node): # FormattedValue(expr value, int? conversion, expr? format_spec) @@ -698,10 +688,7 @@ class Unparser: write("{") expr = StringIO() - unparser = type(self)( - py_ver_consistent=self._py_ver_consistent, - _avoid_backslashes=True, - ) + unparser = type(self)(py_ver_consistent=self._py_ver_consistent, _avoid_backslashes=True) unparser.set_precedence(pnext(_Precedence.TEST), node.value) unparser.visit(node.value, expr) expr = expr.getvalue().rstrip("\n") @@ -940,15 +927,9 @@ class Unparser: self.write(" " + self.cmpops[o.__class__.__name__] + " ") self.dispatch(e) - boolops = { - "And": "and", - "Or": "or", - } + boolops = {"And": "and", "Or": "or"} - boolop_precedence = { - "and": _Precedence.AND, - "or": _Precedence.OR, - } + boolop_precedence = {"and": _Precedence.AND, "or": _Precedence.OR} def visit_BoolOp(self, node): operator = self.boolops[node.op.__class__.__name__] @@ -1224,11 +1205,7 @@ class Unparser: with self.delimit("{", "}"): keys = node.keys - interleave( - lambda: self.write(", "), - write_key_pattern_pair, - zip(keys, node.patterns), - ) + interleave(lambda: self.write(", "), write_key_pattern_pair, zip(keys, node.patterns)) rest = node.rest if rest is not None: if keys: @@ -1252,9 +1229,7 @@ class Unparser: if patterns: self.write(", ") interleave( - lambda: self.write(", "), - write_attr_pattern, - zip(attrs, node.kwd_patterns), + lambda: self.write(", "), write_attr_pattern, zip(attrs, node.kwd_patterns) ) def visit_MatchAs(self, node): diff --git a/lib/spack/spack/util/url.py b/lib/spack/spack/util/url.py index c353d21f41..cacee8f1fb 100644 --- a/lib/spack/spack/util/url.py +++ b/lib/spack/spack/util/url.py @@ -147,11 +147,7 @@ def join(base_url, path, *extra, **kwargs): last_abs_component = None scheme = "" for i in range(n - 1, -1, -1): - obj = urllib.parse.urlparse( - paths[i], - scheme="", - allow_fragments=False, - ) + obj = urllib.parse.urlparse(paths[i], scheme="", allow_fragments=False) scheme = obj.scheme @@ -161,11 +157,7 @@ def join(base_url, path, *extra, **kwargs): # Without a scheme, we have to go back looking for the # next-last component that specifies a scheme. for j in range(i - 1, -1, -1): - obj = urllib.parse.urlparse( - paths[j], - scheme="", - allow_fragments=False, - ) + obj = urllib.parse.urlparse(paths[j], scheme="", allow_fragments=False) if obj.scheme: paths[i] = "{SM}://{NL}{PATH}".format( @@ -181,11 +173,7 @@ def join(base_url, path, *extra, **kwargs): if last_abs_component is not None: paths = paths[last_abs_component:] if len(paths) == 1: - result = urllib.parse.urlparse( - paths[0], - scheme="file", - allow_fragments=False, - ) + result = urllib.parse.urlparse(paths[0], scheme="file", allow_fragments=False) # another subtlety: If the last argument to join() is an absolute # file:// URL component with a relative path, the relative path @@ -250,12 +238,7 @@ def _join(base_url, path, *extra, **kwargs): return format( urllib.parse.ParseResult( - scheme=scheme, - netloc=netloc, - path=base_path, - params=params, - query=query, - fragment=None, + scheme=scheme, netloc=netloc, path=base_path, params=params, query=query, fragment=None ) ) diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py index f389dfc067..2048e794cc 100644 --- a/lib/spack/spack/version.py +++ b/lib/spack/spack/version.py @@ -229,11 +229,7 @@ class VersionBase(object): """ - __slots__ = [ - "version", - "separators", - "string", - ] + __slots__ = ["version", "separators", "string"] def __init__(self, string: str) -> None: if not isinstance(string, str): |