summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <gamblin2@llnl.gov>2021-07-08 15:12:30 -0700
committerGitHub <noreply@github.com>2021-07-08 22:12:30 +0000
commit24c01d57cfb99946eff3af7ec62b71ae6ec72ed8 (patch)
treea9cbe1b7ef49d14c55fada060476b22fa57ef95e /lib
parent620836a80960396487b5eeba41c2a57c0b4674d2 (diff)
downloadspack-24c01d57cfb99946eff3af7ec62b71ae6ec72ed8.tar.gz
spack-24c01d57cfb99946eff3af7ec62b71ae6ec72ed8.tar.bz2
spack-24c01d57cfb99946eff3af7ec62b71ae6ec72ed8.tar.xz
spack-24c01d57cfb99946eff3af7ec62b71ae6ec72ed8.zip
imports: sort imports everywhere in Spack (#24695)
* fix remaining flake8 errors * imports: sort imports everywhere in Spack We enabled import order checking in #23947, but fixing things manually drives people crazy. This used `spack style --fix --all` from #24071 to automatically sort everything in Spack so PR submitters won't have to deal with it. This should go in after #24071, as it assumes we're using `isort`, not `flake8-import-order` to order things. `isort` seems to be more flexible and allows `llnl` mports to be in their own group before `spack` ones, so this seems like a good switch.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/docs/conf.py9
-rw-r--r--lib/spack/llnl/util/argparsewriter.py2
-rw-r--r--lib/spack/llnl/util/filesystem.py5
-rw-r--r--lib/spack/llnl/util/lang.py7
-rw-r--r--lib/spack/llnl/util/link_tree.py4
-rw-r--r--lib/spack/llnl/util/lock.py8
-rw-r--r--lib/spack/llnl/util/tty/__init__.py5
-rw-r--r--lib/spack/llnl/util/tty/colify.py3
-rw-r--r--lib/spack/llnl/util/tty/color.py2
-rw-r--r--lib/spack/llnl/util/tty/log.py9
-rw-r--r--lib/spack/llnl/util/tty/pty.py4
-rw-r--r--lib/spack/spack/abi.py2
-rw-r--r--lib/spack/spack/analyzers/__init__.py5
-rw-r--r--lib/spack/spack/analyzers/analyzer_base.py11
-rw-r--r--lib/spack/spack/analyzers/config_args.py5
-rw-r--r--lib/spack/spack/analyzers/environment_variables.py6
-rw-r--r--lib/spack/spack/analyzers/install_files.py5
-rw-r--r--lib/spack/spack/analyzers/libabigail.py12
-rw-r--r--lib/spack/spack/architecture.py9
-rw-r--r--lib/spack/spack/audit.py2
-rw-r--r--lib/spack/spack/binary_distribution.py21
-rw-r--r--lib/spack/spack/bootstrap.py1
-rw-r--r--lib/spack/spack/build_environment.py36
-rw-r--r--lib/spack/spack/build_systems/aspell_dict.py1
-rw-r--r--lib/spack/spack/build_systems/autotools.py8
-rw-r--r--lib/spack/spack/build_systems/cached_cmake.py2
-rw-r--r--lib/spack/spack/build_systems/cmake.py7
-rw-r--r--lib/spack/spack/build_systems/cuda.py5
-rw-r--r--lib/spack/spack/build_systems/gnu.py2
-rw-r--r--lib/spack/spack/build_systems/intel.py28
-rw-r--r--lib/spack/spack/build_systems/makefile.py1
-rw-r--r--lib/spack/spack/build_systems/maven.py1
-rw-r--r--lib/spack/spack/build_systems/meson.py1
-rw-r--r--lib/spack/spack/build_systems/oneapi.py6
-rw-r--r--lib/spack/spack/build_systems/perl.py3
-rw-r--r--lib/spack/spack/build_systems/python.py16
-rw-r--r--lib/spack/spack/build_systems/qmake.py1
-rw-r--r--lib/spack/spack/build_systems/rocm.py5
-rw-r--r--lib/spack/spack/build_systems/sip.py5
-rw-r--r--lib/spack/spack/build_systems/sourceforge.py2
-rw-r--r--lib/spack/spack/build_systems/sourceware.py2
-rw-r--r--lib/spack/spack/build_systems/waf.py4
-rw-r--r--lib/spack/spack/build_systems/xorg.py2
-rw-r--r--lib/spack/spack/caches.py4
-rw-r--r--lib/spack/spack/ci.py2
-rw-r--r--lib/spack/spack/cmd/__init__.py9
-rw-r--r--lib/spack/spack/cmd/add.py1
-rw-r--r--lib/spack/spack/cmd/analyze.py1
-rw-r--r--lib/spack/spack/cmd/arch.py2
-rw-r--r--lib/spack/spack/cmd/audit.py2
-rw-r--r--lib/spack/spack/cmd/blame.py7
-rw-r--r--lib/spack/spack/cmd/buildcache.py9
-rw-r--r--lib/spack/spack/cmd/checksum.py2
-rw-r--r--lib/spack/spack/cmd/ci.py2
-rw-r--r--lib/spack/spack/cmd/clean.py5
-rw-r--r--lib/spack/spack/cmd/commands.py5
-rw-r--r--lib/spack/spack/cmd/common/env_utility.py3
-rw-r--r--lib/spack/spack/cmd/compiler.py10
-rw-r--r--lib/spack/spack/cmd/config.py9
-rw-r--r--lib/spack/spack/cmd/containerize.py1
-rw-r--r--lib/spack/spack/cmd/create.py19
-rw-r--r--lib/spack/spack/cmd/deprecate.py6
-rw-r--r--lib/spack/spack/cmd/dev_build.py4
-rw-r--r--lib/spack/spack/cmd/develop.py1
-rw-r--r--lib/spack/spack/cmd/edit.py2
-rw-r--r--lib/spack/spack/cmd/env.py11
-rw-r--r--lib/spack/spack/cmd/extensions.py2
-rw-r--r--lib/spack/spack/cmd/external.py4
-rw-r--r--lib/spack/spack/cmd/find.py8
-rw-r--r--lib/spack/spack/cmd/flake8.py1
-rw-r--r--lib/spack/spack/cmd/gpg.py2
-rw-r--r--lib/spack/spack/cmd/graph.py2
-rw-r--r--lib/spack/spack/cmd/help.py1
-rw-r--r--lib/spack/spack/cmd/info.py4
-rw-r--r--lib/spack/spack/cmd/install.py1
-rw-r--r--lib/spack/spack/cmd/list.py9
-rw-r--r--lib/spack/spack/cmd/load.py4
-rw-r--r--lib/spack/spack/cmd/location.py3
-rw-r--r--lib/spack/spack/cmd/log_parse.py3
-rw-r--r--lib/spack/spack/cmd/maintainers.py1
-rw-r--r--lib/spack/spack/cmd/mark.py6
-rw-r--r--lib/spack/spack/cmd/mirror.py3
-rw-r--r--lib/spack/spack/cmd/module.py2
-rw-r--r--lib/spack/spack/cmd/modules/__init__.py5
-rw-r--r--lib/spack/spack/cmd/modules/lmod.py1
-rw-r--r--lib/spack/spack/cmd/monitor.py1
-rw-r--r--lib/spack/spack/cmd/patch.py3
-rw-r--r--lib/spack/spack/cmd/pkg.py2
-rw-r--r--lib/spack/spack/cmd/providers.py3
-rw-r--r--lib/spack/spack/cmd/python.py6
-rw-r--r--lib/spack/spack/cmd/remove.py1
-rw-r--r--lib/spack/spack/cmd/repo.py1
-rw-r--r--lib/spack/spack/cmd/resource.py2
-rw-r--r--lib/spack/spack/cmd/spec.py2
-rw-r--r--lib/spack/spack/cmd/stage.py4
-rw-r--r--lib/spack/spack/cmd/test.py11
-rw-r--r--lib/spack/spack/cmd/tutorial.py1
-rw-r--r--lib/spack/spack/cmd/undevelop.py1
-rw-r--r--lib/spack/spack/cmd/uninstall.py10
-rw-r--r--lib/spack/spack/cmd/unit_test.py8
-rw-r--r--lib/spack/spack/cmd/unload.py6
-rw-r--r--lib/spack/spack/cmd/url.py24
-rw-r--r--lib/spack/spack/cmd/verify.py3
-rw-r--r--lib/spack/spack/cmd/versions.py4
-rw-r--r--lib/spack/spack/cmd/view.py12
-rw-r--r--lib/spack/spack/compiler.py13
-rw-r--r--lib/spack/spack/compilers/__init__.py17
-rw-r--r--lib/spack/spack/compilers/apple_clang.py3
-rw-r--r--lib/spack/spack/compilers/arm.py3
-rw-r--r--lib/spack/spack/compilers/clang.py1
-rw-r--r--lib/spack/spack/compilers/gcc.py1
-rw-r--r--lib/spack/spack/concretize.py24
-rw-r--r--lib/spack/spack/config.py19
-rw-r--r--lib/spack/spack/container/__init__.py1
-rw-r--r--lib/spack/spack/container/writers/__init__.py5
-rw-r--r--lib/spack/spack/container/writers/docker.py2
-rw-r--r--lib/spack/spack/container/writers/singularity.py3
-rw-r--r--lib/spack/spack/database.py1
-rw-r--r--lib/spack/spack/dependency.py1
-rw-r--r--lib/spack/spack/directives.py2
-rw-r--r--lib/spack/spack/directory_layout.py8
-rw-r--r--lib/spack/spack/environment.py26
-rw-r--r--lib/spack/spack/error.py3
-rw-r--r--lib/spack/spack/extensions.py1
-rw-r--r--lib/spack/spack/fetch_strategy.py10
-rw-r--r--lib/spack/spack/filesystem_view.py30
-rw-r--r--lib/spack/spack/graph.py1
-rw-r--r--lib/spack/spack/hooks/__init__.py1
-rw-r--r--lib/spack/spack/hooks/module_file_generation.py3
-rw-r--r--lib/spack/spack/hooks/monitor.py1
-rw-r--r--lib/spack/spack/hooks/permissions_setters.py1
-rw-r--r--lib/spack/spack/hooks/sbang.py4
-rw-r--r--lib/spack/spack/install_test.py4
-rw-r--r--lib/spack/spack/installer.py6
-rw-r--r--lib/spack/spack/main.py6
-rw-r--r--lib/spack/spack/mirror.py16
-rw-r--r--lib/spack/spack/mixins.py1
-rw-r--r--lib/spack/spack/modules/__init__.py2
-rw-r--r--lib/spack/spack/modules/common.py5
-rw-r--r--lib/spack/spack/modules/lmod.py15
-rw-r--r--lib/spack/spack/modules/tcl.py6
-rw-r--r--lib/spack/spack/monitor.py16
-rw-r--r--lib/spack/spack/multimethod.py3
-rw-r--r--lib/spack/spack/operating_systems/linux_distro.py1
-rw-r--r--lib/spack/spack/operating_systems/mac_os.py2
-rw-r--r--lib/spack/spack/package.py6
-rw-r--r--lib/spack/spack/package_prefs.py6
-rw-r--r--lib/spack/spack/package_test.py3
-rw-r--r--lib/spack/spack/parse.py3
-rw-r--r--lib/spack/spack/patch.py7
-rw-r--r--lib/spack/spack/paths.py1
-rw-r--r--lib/spack/spack/pkgkit.py84
-rw-r--r--lib/spack/spack/platforms/cray.py10
-rw-r--r--lib/spack/spack/platforms/test.py4
-rw-r--r--lib/spack/spack/provider_index.py1
-rw-r--r--lib/spack/spack/relocate.py8
-rw-r--r--lib/spack/spack/repo.py14
-rw-r--r--lib/spack/spack/report.py3
-rw-r--r--lib/spack/spack/reporters/cdash.py8
-rw-r--r--lib/spack/spack/s3_handler.py4
-rw-r--r--lib/spack/spack/schema/__init__.py1
-rw-r--r--lib/spack/spack/schema/buildcache_spec.py1
-rw-r--r--lib/spack/spack/schema/config.py2
-rw-r--r--lib/spack/spack/schema/environment.py1
-rw-r--r--lib/spack/spack/schema/merged.py1
-rw-r--r--lib/spack/spack/schema/packages.py3
-rw-r--r--lib/spack/spack/solver/asp.py8
-rw-r--r--lib/spack/spack/spec.py13
-rw-r--r--lib/spack/spack/spec_list.py3
-rw-r--r--lib/spack/spack/stage.py24
-rw-r--r--lib/spack/spack/store.py6
-rw-r--r--lib/spack/spack/subprocess_context.py8
-rw-r--r--lib/spack/spack/tengine.py3
-rw-r--r--lib/spack/spack/test/architecture.py4
-rw-r--r--lib/spack/spack/test/bindist.py3
-rw-r--r--lib/spack/spack/test/build_distribution.py6
-rw-r--r--lib/spack/spack/test/build_environment.py12
-rw-r--r--lib/spack/spack/test/build_system_guess.py3
-rw-r--r--lib/spack/spack/test/build_systems.py3
-rw-r--r--lib/spack/spack/test/cache_fetch.py4
-rw-r--r--lib/spack/spack/test/cc.py3
-rw-r--r--lib/spack/spack/test/ci.py13
-rw-r--r--lib/spack/spack/test/cmd/analyze.py6
-rw-r--r--lib/spack/spack/test/cmd/arch.py1
-rw-r--r--lib/spack/spack/test/cmd/audit.py1
-rw-r--r--lib/spack/spack/test/cmd/blame.py4
-rw-r--r--lib/spack/spack/test/cmd/build_env.py2
-rw-r--r--lib/spack/spack/test/cmd/buildcache.py4
-rw-r--r--lib/spack/spack/test/cmd/cd.py1
-rw-r--r--lib/spack/spack/test/cmd/ci.py1
-rw-r--r--lib/spack/spack/test/cmd/clean.py3
-rw-r--r--lib/spack/spack/test/cmd/commands.py3
-rw-r--r--lib/spack/spack/test/cmd/compiler.py1
-rw-r--r--lib/spack/spack/test/cmd/concretize.py2
-rw-r--r--lib/spack/spack/test/cmd/config.py6
-rw-r--r--lib/spack/spack/test/cmd/create.py4
-rw-r--r--lib/spack/spack/test/cmd/debug.py5
-rw-r--r--lib/spack/spack/test/cmd/dependencies.py1
-rw-r--r--lib/spack/spack/test/cmd/deprecate.py3
-rw-r--r--lib/spack/spack/test/cmd/dev_build.py5
-rw-r--r--lib/spack/spack/test/cmd/develop.py6
-rw-r--r--lib/spack/spack/test/cmd/env.py11
-rw-r--r--lib/spack/spack/test/cmd/extensions.py1
-rw-r--r--lib/spack/spack/test/cmd/external.py6
-rw-r--r--lib/spack/spack/test/cmd/fetch.py2
-rw-r--r--lib/spack/spack/test/cmd/find.py4
-rw-r--r--lib/spack/spack/test/cmd/gc.py2
-rw-r--r--lib/spack/spack/test/cmd/gpg.py4
-rw-r--r--lib/spack/spack/test/cmd/graph.py3
-rw-r--r--lib/spack/spack/test/cmd/info.py2
-rw-r--r--lib/spack/spack/test/cmd/init_py_functions.py11
-rw-r--r--lib/spack/spack/test/cmd/install.py17
-rw-r--r--lib/spack/spack/test/cmd/is_git_repo.py3
-rw-r--r--lib/spack/spack/test/cmd/license.py2
-rw-r--r--lib/spack/spack/test/cmd/load.py4
-rw-r--r--lib/spack/spack/test/cmd/location.py5
-rw-r--r--lib/spack/spack/test/cmd/maintainers.py3
-rw-r--r--lib/spack/spack/test/cmd/mark.py1
-rw-r--r--lib/spack/spack/test/cmd/mirror.py7
-rw-r--r--lib/spack/spack/test/cmd/pkg.py5
-rw-r--r--lib/spack/spack/test/cmd/reindex.py3
-rw-r--r--lib/spack/spack/test/cmd/repo.py1
-rw-r--r--lib/spack/spack/test/cmd/resource.py1
-rw-r--r--lib/spack/spack/test/cmd/spec.py1
-rw-r--r--lib/spack/spack/test/cmd/stage.py5
-rw-r--r--lib/spack/spack/test/cmd/test.py3
-rw-r--r--lib/spack/spack/test/cmd/undevelop.py2
-rw-r--r--lib/spack/spack/test/cmd/uninstall.py2
-rw-r--r--lib/spack/spack/test/cmd/url.py6
-rw-r--r--lib/spack/spack/test/cmd/verify.py4
-rw-r--r--lib/spack/spack/test/cmd/view.py3
-rw-r--r--lib/spack/spack/test/cmd_extensions.py4
-rw-r--r--lib/spack/spack/test/compilers/basics.py9
-rw-r--r--lib/spack/spack/test/compilers/detection.py1
-rw-r--r--lib/spack/spack/test/concretize.py9
-rw-r--r--lib/spack/spack/test/concretize_preferences.py5
-rw-r--r--lib/spack/spack/test/config.py17
-rw-r--r--lib/spack/spack/test/container/cli.py2
-rw-r--r--lib/spack/spack/test/cvs_fetch.py9
-rw-r--r--lib/spack/spack/test/database.py13
-rw-r--r--lib/spack/spack/test/directory_layout.py7
-rw-r--r--lib/spack/spack/test/environment_modifications.py16
-rw-r--r--lib/spack/spack/test/flag_handlers.py10
-rw-r--r--lib/spack/spack/test/git_fetch.py8
-rw-r--r--lib/spack/spack/test/graph.py2
-rw-r--r--lib/spack/spack/test/hg_fetch.py9
-rw-r--r--lib/spack/spack/test/install.py12
-rw-r--r--lib/spack/spack/test/installer.py3
-rw-r--r--lib/spack/spack/test/link_paths.py3
-rw-r--r--lib/spack/spack/test/llnl/util/argparsewriter.py1
-rw-r--r--lib/spack/spack/test/llnl/util/file_list.py13
-rw-r--r--lib/spack/spack/test/llnl/util/filesystem.py1
-rw-r--r--lib/spack/spack/test/llnl/util/lang.py6
-rw-r--r--lib/spack/spack/test/llnl/util/link_tree.py4
-rw-r--r--lib/spack/spack/test/llnl/util/lock.py7
-rw-r--r--lib/spack/spack/test/llnl/util/tty/log.py4
-rw-r--r--lib/spack/spack/test/llnl/util/tty/tty.py1
-rw-r--r--lib/spack/spack/test/mirror.py7
-rw-r--r--lib/spack/spack/test/module_parsing.py9
-rw-r--r--lib/spack/spack/test/modules/common.py8
-rw-r--r--lib/spack/spack/test/modules/conftest.py2
-rw-r--r--lib/spack/spack/test/modules/lmod.py1
-rw-r--r--lib/spack/spack/test/monitor.py11
-rw-r--r--lib/spack/spack/test/multimethod.py1
-rw-r--r--lib/spack/spack/test/optional_deps.py1
-rw-r--r--lib/spack/spack/test/package_class.py3
-rw-r--r--lib/spack/spack/test/package_hash.py2
-rw-r--r--lib/spack/spack/test/package_sanity.py14
-rw-r--r--lib/spack/spack/test/packages.py10
-rw-r--r--lib/spack/spack/test/packaging.py34
-rw-r--r--lib/spack/spack/test/patch.py11
-rw-r--r--lib/spack/spack/test/pattern.py1
-rw-r--r--lib/spack/spack/test/permissions.py8
-rw-r--r--lib/spack/spack/test/relocate.py4
-rw-r--r--lib/spack/spack/test/repo.py3
-rw-r--r--lib/spack/spack/test/s3_fetch.py1
-rw-r--r--lib/spack/spack/test/sbang.py10
-rw-r--r--lib/spack/spack/test/spec_dag.py6
-rw-r--r--lib/spack/spack/test/spec_list.py6
-rw-r--r--lib/spack/spack/test/spec_semantics.py21
-rw-r--r--lib/spack/spack/test/spec_syntax.py27
-rw-r--r--lib/spack/spack/test/spec_yaml.py4
-rw-r--r--lib/spack/spack/test/stage.py7
-rw-r--r--lib/spack/spack/test/svn_fetch.py9
-rw-r--r--lib/spack/spack/test/tengine.py4
-rw-r--r--lib/spack/spack/test/test_activations.py6
-rw-r--r--lib/spack/spack/test/test_suite.py1
-rw-r--r--lib/spack/spack/test/url_fetch.py13
-rw-r--r--lib/spack/spack/test/url_parse.py14
-rw-r--r--lib/spack/spack/test/url_substitution.py1
-rw-r--r--lib/spack/spack/test/util/editor.py2
-rw-r--r--lib/spack/spack/test/util/environment.py4
-rw-r--r--lib/spack/spack/test/util/executable.py2
-rw-r--r--lib/spack/spack/test/util/file_cache.py1
-rw-r--r--lib/spack/spack/test/util/util_gpg.py1
-rw-r--r--lib/spack/spack/test/util/util_url.py1
-rw-r--r--lib/spack/spack/test/variant.py22
-rw-r--r--lib/spack/spack/test/verification.py4
-rw-r--r--lib/spack/spack/test/views.py2
-rw-r--r--lib/spack/spack/test/web.py7
-rw-r--r--lib/spack/spack/url.py1
-rw-r--r--lib/spack/spack/user_environment.py6
-rw-r--r--lib/spack/spack/util/classes.py8
-rw-r--r--lib/spack/spack/util/compression.py3
-rw-r--r--lib/spack/spack/util/cpus.py2
-rw-r--r--lib/spack/spack/util/crypto.py4
-rw-r--r--lib/spack/spack/util/debug.py4
-rw-r--r--lib/spack/spack/util/editor.py1
-rw-r--r--lib/spack/spack/util/environment.py11
-rw-r--r--lib/spack/spack/util/executable.py4
-rw-r--r--lib/spack/spack/util/file_permissions.py2
-rw-r--r--lib/spack/spack/util/gpg.py1
-rw-r--r--lib/spack/spack/util/lock.py3
-rw-r--r--lib/spack/spack/util/log_parse.py4
-rw-r--r--lib/spack/spack/util/mock_package.py2
-rw-r--r--lib/spack/spack/util/module_cmd.py9
-rw-r--r--lib/spack/spack/util/naming.py4
-rw-r--r--lib/spack/spack/util/package_hash.py4
-rw-r--r--lib/spack/spack/util/path.py2
-rw-r--r--lib/spack/spack/util/pattern.py3
-rw-r--r--lib/spack/spack/util/spack_json.py6
-rw-r--r--lib/spack/spack/util/spack_yaml.py10
-rw-r--r--lib/spack/spack/util/timer.py5
-rw-r--r--lib/spack/spack/util/web.py9
-rw-r--r--lib/spack/spack/variant.py7
-rw-r--r--lib/spack/spack/verify.py10
-rw-r--r--lib/spack/spack/version.py4
327 files changed, 1045 insertions, 863 deletions
diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py
index 2de12a5a99..38d75747e3 100644
--- a/lib/spack/docs/conf.py
+++ b/lib/spack/docs/conf.py
@@ -17,10 +17,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys
import os
import re
import subprocess
+import sys
from glob import glob
from sphinx.ext.apidoc import main as sphinx_apidoc
@@ -82,6 +82,8 @@ todo_include_todos = True
# Disable duplicate cross-reference warnings.
#
from sphinx.domains.python import PythonDomain
+
+
class PatchedPythonDomain(PythonDomain):
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if 'refspecific' in node:
@@ -136,6 +138,7 @@ copyright = u'2013-2021, Lawrence Livermore National Laboratory.'
#
# The short X.Y version.
import spack
+
version = '.'.join(str(s) for s in spack.spack_version_info[:2])
# The full version, including alpha/beta/rc tags.
release = spack.spack_version
@@ -179,7 +182,8 @@ exclude_patterns = ['_build', '_spack_root', '.spack-env']
# We use our own extension of the default style with a few modifications
from pygments.style import Style
from pygments.styles.default import DefaultStyle
-from pygments.token import Generic, Comment, Text
+from pygments.token import Comment, Generic, Text
+
class SpackStyle(DefaultStyle):
styles = DefaultStyle.styles.copy()
@@ -188,6 +192,7 @@ class SpackStyle(DefaultStyle):
styles[Generic.Prompt] = "bold #346ec9"
import pkg_resources
+
dist = pkg_resources.Distribution(__file__)
sys.path.append('.') # make 'conf' module findable
ep = pkg_resources.EntryPoint.parse('spack = conf:SpackStyle', dist=dist)
diff --git a/lib/spack/llnl/util/argparsewriter.py b/lib/spack/llnl/util/argparsewriter.py
index 9b90096460..6d44713e39 100644
--- a/lib/spack/llnl/util/argparsewriter.py
+++ b/lib/spack/llnl/util/argparsewriter.py
@@ -5,9 +5,9 @@
from __future__ import print_function
-import re
import argparse
import errno
+import re
import sys
from six import StringIO
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index c7ecf09af2..0ebc35a040 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -4,9 +4,9 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import collections
import errno
-import hashlib
import glob
import grp
+import hashlib
import itertools
import numbers
import os
@@ -19,10 +19,11 @@ import tempfile
from contextlib import contextmanager
import six
+
from llnl.util import tty
from llnl.util.lang import dedupe, memoized
-from spack.util.executable import Executable
+from spack.util.executable import Executable
if sys.version_info >= (3, 3):
from collections.abc import Sequence # novm
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index b20cd91db4..00b0490600 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -5,14 +5,15 @@
from __future__ import division
+import functools
+import inspect
import multiprocessing
import os
import re
-import functools
-import inspect
+import sys
from datetime import datetime, timedelta
+
from six import string_types
-import sys
if sys.version_info < (3, 0):
from itertools import izip_longest # novm
diff --git a/lib/spack/llnl/util/link_tree.py b/lib/spack/llnl/util/link_tree.py
index c286671401..f5a9e49fbb 100644
--- a/lib/spack/llnl/util/link_tree.py
+++ b/lib/spack/llnl/util/link_tree.py
@@ -7,12 +7,12 @@
from __future__ import print_function
+import filecmp
import os
import shutil
-import filecmp
-from llnl.util.filesystem import traverse_tree, mkdirp, touch
import llnl.util.tty as tty
+from llnl.util.filesystem import mkdirp, touch, traverse_tree
__all__ = ['LinkTree']
diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py
index bd3308a57f..cd390693c4 100644
--- a/lib/spack/llnl/util/lock.py
+++ b/lib/spack/llnl/util/lock.py
@@ -3,16 +3,16 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
-import fcntl
import errno
-import time
+import fcntl
+import os
import socket
+import time
from datetime import datetime
import llnl.util.tty as tty
-import spack.util.string
+import spack.util.string
__all__ = ['Lock', 'LockTransaction', 'WriteTransaction', 'ReadTransaction',
'LockError', 'LockTimeoutError',
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py
index cf70834e8d..987e226d5d 100644
--- a/lib/spack/llnl/util/tty/__init__.py
+++ b/lib/spack/llnl/util/tty/__init__.py
@@ -12,12 +12,13 @@ import sys
import termios
import textwrap
import traceback
-import six
from datetime import datetime
+
+import six
from six import StringIO
from six.moves import input
-from llnl.util.tty.color import cprint, cwrite, cescape, clen
+from llnl.util.tty.color import cescape, clen, cprint, cwrite
# Globals
_debug = 0
diff --git a/lib/spack/llnl/util/tty/colify.py b/lib/spack/llnl/util/tty/colify.py
index 56baeb5bfb..ca157e3303 100644
--- a/lib/spack/llnl/util/tty/colify.py
+++ b/lib/spack/llnl/util/tty/colify.py
@@ -10,10 +10,11 @@ from __future__ import division, unicode_literals
import os
import sys
+
from six import StringIO, text_type
from llnl.util.tty import terminal_size
-from llnl.util.tty.color import clen, cextra
+from llnl.util.tty.color import cextra, clen
class ColumnConfig:
diff --git a/lib/spack/llnl/util/tty/color.py b/lib/spack/llnl/util/tty/color.py
index ffd1b8c497..78f0e75a97 100644
--- a/lib/spack/llnl/util/tty/color.py
+++ b/lib/spack/llnl/util/tty/color.py
@@ -60,9 +60,9 @@ The console can be reset later to plain text with '@.'.
To output an @, use '@@'. To output a } inside braces, use '}}'.
"""
from __future__ import unicode_literals
+
import re
import sys
-
from contextlib import contextmanager
import six
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index 28f4f06edf..947e79b8c9 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -13,15 +13,14 @@ import multiprocessing
import os
import re
import select
+import signal
import sys
import traceback
-import signal
from contextlib import contextmanager
-from six import string_types
-from six import StringIO
-
-from typing import Optional # novm
from types import ModuleType # novm
+from typing import Optional # novm
+
+from six import StringIO, string_types
import llnl.util.tty as tty
diff --git a/lib/spack/llnl/util/tty/pty.py b/lib/spack/llnl/util/tty/pty.py
index 2a5fb7afa4..a0076a8b71 100644
--- a/lib/spack/llnl/util/tty/pty.py
+++ b/lib/spack/llnl/util/tty/pty.py
@@ -14,10 +14,10 @@ get tests done quickly, not to avoid high CPU usage.
"""
from __future__ import print_function
-import os
-import signal
import multiprocessing
+import os
import re
+import signal
import sys
import termios
import time
diff --git a/lib/spack/spack/abi.py b/lib/spack/spack/abi.py
index da796e2100..cebf3f8192 100644
--- a/lib/spack/spack/abi.py
+++ b/lib/spack/spack/abi.py
@@ -8,9 +8,9 @@ import os
from llnl.util.lang import memoized
import spack.spec
+from spack.compilers.clang import Clang
from spack.spec import CompilerSpec
from spack.util.executable import Executable, ProcessError
-from spack.compilers.clang import Clang
class ABI(object):
diff --git a/lib/spack/spack/analyzers/__init__.py b/lib/spack/spack/analyzers/__init__.py
index 9e36ed7b3f..6eb63776c5 100644
--- a/lib/spack/spack/analyzers/__init__.py
+++ b/lib/spack/spack/analyzers/__init__.py
@@ -10,11 +10,10 @@ existing metadata.
from __future__ import absolute_import
-import spack.util.classes
-import spack.paths
-
import llnl.util.tty as tty
+import spack.paths
+import spack.util.classes
mod_path = spack.paths.analyzers_path
analyzers = spack.util.classes.list_classes("spack.analyzers", mod_path)
diff --git a/lib/spack/spack/analyzers/analyzer_base.py b/lib/spack/spack/analyzers/analyzer_base.py
index 41f456b71a..f1f5b8a50c 100644
--- a/lib/spack/spack/analyzers/analyzer_base.py
+++ b/lib/spack/spack/analyzers/analyzer_base.py
@@ -7,13 +7,14 @@
and (optionally) interact with a Spack Monitor
"""
-import spack.monitor
-import spack.hooks
+import os
+
import llnl.util.tty as tty
-import spack.util.path
-import spack.config
-import os
+import spack.config
+import spack.hooks
+import spack.monitor
+import spack.util.path
def get_analyzer_dir(spec, analyzer_dir=None):
diff --git a/lib/spack/spack/analyzers/config_args.py b/lib/spack/spack/analyzers/config_args.py
index f29993dcb3..3a4aa01ce7 100644
--- a/lib/spack/spack/analyzers/config_args.py
+++ b/lib/spack/spack/analyzers/config_args.py
@@ -8,10 +8,11 @@ already existing metadata about config args from a package spec install
directory."""
+import os
+
import spack.monitor
-from .analyzer_base import AnalyzerBase
-import os
+from .analyzer_base import AnalyzerBase
class ConfigArgs(AnalyzerBase):
diff --git a/lib/spack/spack/analyzers/environment_variables.py b/lib/spack/spack/analyzers/environment_variables.py
index 33c4034e31..2d235e7a50 100644
--- a/lib/spack/spack/analyzers/environment_variables.py
+++ b/lib/spack/spack/analyzers/environment_variables.py
@@ -8,11 +8,11 @@ file in the installed package directory, generating a json file that has
an index of key, value pairs for environment variables."""
-from .analyzer_base import AnalyzerBase
-from spack.util.environment import EnvironmentModifications
+import os
+from spack.util.environment import EnvironmentModifications
-import os
+from .analyzer_base import AnalyzerBase
class EnvironmentVariables(AnalyzerBase):
diff --git a/lib/spack/spack/analyzers/install_files.py b/lib/spack/spack/analyzers/install_files.py
index bdebac50fc..1c2d38ce51 100644
--- a/lib/spack/spack/analyzers/install_files.py
+++ b/lib/spack/spack/analyzers/install_files.py
@@ -8,10 +8,11 @@ the package install folder, so this analyzer simply moves it to the user
analyzer folder for further processing."""
+import os
+
import spack.monitor
-from .analyzer_base import AnalyzerBase
-import os
+from .analyzer_base import AnalyzerBase
class InstallFiles(AnalyzerBase):
diff --git a/lib/spack/spack/analyzers/libabigail.py b/lib/spack/spack/analyzers/libabigail.py
index b53369b75f..9b26f3ca6f 100644
--- a/lib/spack/spack/analyzers/libabigail.py
+++ b/lib/spack/spack/analyzers/libabigail.py
@@ -4,21 +4,21 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+import llnl.util.tty as tty
+
import spack
-import spack.error
+import spack.binary_distribution
import spack.bootstrap
+import spack.error
import spack.hooks
import spack.monitor
-import spack.binary_distribution
import spack.package
import spack.repo
-import llnl.util.tty as tty
-
from .analyzer_base import AnalyzerBase
-import os
-
class Libabigail(AnalyzerBase):
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index 04cd85be49..951109c892 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -60,20 +60,21 @@ import contextlib
import functools
import warnings
-import archspec.cpu
import six
-import llnl.util.tty as tty
+import archspec.cpu
+
import llnl.util.lang as lang
+import llnl.util.tty as tty
import spack.compiler
import spack.compilers
import spack.config
-import spack.paths
import spack.error as serr
+import spack.paths
+import spack.util.classes
import spack.util.executable
import spack.version
-import spack.util.classes
from spack.util.spack_yaml import syaml_dict
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py
index c9acdc39d2..76616f31e0 100644
--- a/lib/spack/spack/audit.py
+++ b/lib/spack/spack/audit.py
@@ -37,6 +37,7 @@ as input.
"""
import collections
import itertools
+
try:
from collections.abc import Sequence # novm
except ImportError:
@@ -265,6 +266,7 @@ package_directives = AuditClass(
def _unknown_variants_in_directives(pkgs, error_cls):
"""Report unknown or wrong variants in directives for this package"""
import llnl.util.lang
+
import spack.repo
import spack.spec
diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py
index 46ca4fe88a..6ca15df122 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -4,22 +4,20 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import codecs
+import glob
+import hashlib
+import json
import os
import re
+import shutil
import sys
import tarfile
-import shutil
import tempfile
-import hashlib
-import glob
-from ordereddict_backport import OrderedDict
-
from contextlib import closing
-import ruamel.yaml as yaml
-import json
-
-from six.moves.urllib.error import URLError, HTTPError
+import ruamel.yaml as yaml
+from ordereddict_backport import OrderedDict
+from six.moves.urllib.error import HTTPError, URLError
import llnl.util.lang
import llnl.util.tty as tty
@@ -29,19 +27,18 @@ import spack.cmd
import spack.config as config
import spack.database as spack_db
import spack.fetch_strategy as fs
-import spack.util.file_cache as file_cache
+import spack.mirror
import spack.relocate as relocate
+import spack.util.file_cache as file_cache
import spack.util.gpg
import spack.util.spack_json as sjson
import spack.util.spack_yaml as syaml
-import spack.mirror
import spack.util.url as url_util
import spack.util.web as web_util
from spack.caches import misc_cache_location
from spack.spec import Spec
from spack.stage import Stage
-
_build_cache_relative_path = 'build_cache'
_build_cache_keys_relative_path = '_pgp'
diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py
index 6a536ce6a7..86c3110983 100644
--- a/lib/spack/spack/bootstrap.py
+++ b/lib/spack/spack/bootstrap.py
@@ -5,6 +5,7 @@
import contextlib
import os
import sys
+
try:
import sysconfig # novm
except ImportError:
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index a79a678825..c9be0bc1d8 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -33,44 +33,52 @@ Skimming this module is a nice way to get acquainted with the types of
calls you can make from within the install() function.
"""
import inspect
-import re
import multiprocessing
import os
+import re
import shutil
import sys
import traceback
import types
+
from six import StringIO
import llnl.util.tty as tty
-from llnl.util.tty.color import cescape, colorize
-from llnl.util.filesystem import mkdirp, install, install_tree
+from llnl.util.filesystem import install, install_tree, mkdirp
from llnl.util.lang import dedupe
+from llnl.util.tty.color import cescape, colorize
from llnl.util.tty.log import MultiProcessFd
+import spack.architecture as arch
import spack.build_systems.cmake
import spack.build_systems.meson
import spack.config
+import spack.install_test
import spack.main
-import spack.paths
import spack.package
+import spack.paths
import spack.repo
import spack.schema.environment
import spack.store
-import spack.install_test
import spack.subprocess_context
-import spack.architecture as arch
import spack.util.path
-from spack.util.string import plural
+from spack.error import NoHeadersError, NoLibrariesError
+from spack.util.cpus import cpus_available
from spack.util.environment import (
- env_flag, filter_system_paths, get_path, is_system_path,
- EnvironmentModifications, validate, preserve_environment)
-from spack.util.environment import system_dirs
-from spack.error import NoLibrariesError, NoHeadersError
+ EnvironmentModifications,
+ env_flag,
+ filter_system_paths,
+ get_path,
+ is_system_path,
+ preserve_environment,
+ system_dirs,
+ validate,
+)
from spack.util.executable import Executable
-from spack.util.module_cmd import load_module, path_from_modules, module
-from spack.util.log_parse import parse_log_events, make_log_context
-from spack.util.cpus import cpus_available
+from spack.util.log_parse import make_log_context, parse_log_events
+from spack.util.module_cmd import load_module, module, path_from_modules
+from spack.util.string import plural
+
#
# This can be set by the user to globally disable parallel builds.
#
diff --git a/lib/spack/spack/build_systems/aspell_dict.py b/lib/spack/spack/build_systems/aspell_dict.py
index 55ea78145a..286f955455 100644
--- a/lib/spack/spack/build_systems/aspell_dict.py
+++ b/lib/spack/spack/build_systems/aspell_dict.py
@@ -6,6 +6,7 @@
# Why doesn't this work for me?
# from spack import *
from llnl.util.filesystem import filter_file
+
from spack.build_systems.autotools import AutotoolsPackage
from spack.directives import extends
from spack.package import ExtensionError
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py
index 2ab1b4a8fb..7ded0245de 100644
--- a/lib/spack/spack/build_systems/autotools.py
+++ b/lib/spack/spack/build_systems/autotools.py
@@ -7,13 +7,13 @@ import itertools
import os
import os.path
import stat
-from subprocess import PIPE
-from subprocess import check_call
+from subprocess import PIPE, check_call
from typing import List # novm
-import llnl.util.tty as tty
import llnl.util.filesystem as fs
-from llnl.util.filesystem import working_dir, force_remove
+import llnl.util.tty as tty
+from llnl.util.filesystem import force_remove, working_dir
+
from spack.package import PackageBase, run_after, run_before
from spack.util.executable import Executable
diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py
index 2c3e150528..c143c824de 100644
--- a/lib/spack/spack/build_systems/cached_cmake.py
+++ b/lib/spack/spack/build_systems/cached_cmake.py
@@ -4,8 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
-from llnl.util.filesystem import install, mkdirp
import llnl.util.tty as tty
+from llnl.util.filesystem import install, mkdirp
from spack.build_systems.cmake import CMakePackage
from spack.package import run_after
diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py
index b6b6c30dce..acf4a9dc53 100644
--- a/lib/spack/spack/build_systems/cmake.py
+++ b/lib/spack/spack/build_systems/cmake.py
@@ -10,10 +10,11 @@ import platform
import re
from typing import List # novm
-import spack.build_environment
from llnl.util.filesystem import working_dir
-from spack.directives import depends_on, variant, conflicts
-from spack.package import PackageBase, InstallError, run_after
+
+import spack.build_environment
+from spack.directives import conflicts, depends_on, variant
+from spack.package import InstallError, PackageBase, run_after
# Regex to extract the primary generator from the CMake generator
# string.
diff --git a/lib/spack/spack/build_systems/cuda.py b/lib/spack/spack/build_systems/cuda.py
index 8a899b0f81..b2b7783500 100644
--- a/lib/spack/spack/build_systems/cuda.py
+++ b/lib/spack/spack/build_systems/cuda.py
@@ -3,10 +3,9 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from spack.package import PackageBase
-from spack.directives import depends_on, variant, conflicts
-
import spack.variant
+from spack.directives import conflicts, depends_on, variant
+from spack.package import PackageBase
class CudaPackage(PackageBase):
diff --git a/lib/spack/spack/build_systems/gnu.py b/lib/spack/spack/build_systems/gnu.py
index 6f5771214e..b027546974 100644
--- a/lib/spack/spack/build_systems/gnu.py
+++ b/lib/spack/spack/build_systems/gnu.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import spack.util.url
import spack.package
+import spack.util.url
class GNUMirrorPackage(spack.package.PackageBase):
diff --git a/lib/spack/spack/build_systems/intel.py b/lib/spack/spack/build_systems/intel.py
index 9c0eb30a82..2049669aea 100644
--- a/lib/spack/spack/build_systems/intel.py
+++ b/lib/spack/spack/build_systems/intel.py
@@ -4,26 +4,32 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import glob
+import inspect
import os
+import re
import sys
-import glob
import tempfile
-import re
-import inspect
import xml.etree.ElementTree as ElementTree
-import llnl.util.tty as tty
-from llnl.util.filesystem import \
- install, ancestor, filter_file, \
- HeaderList, find_headers, \
- LibraryList, find_libraries, find_system_libraries
+import llnl.util.tty as tty
+from llnl.util.filesystem import (
+ HeaderList,
+ LibraryList,
+ ancestor,
+ filter_file,
+ find_headers,
+ find_libraries,
+ find_system_libraries,
+ install,
+)
-from spack.version import Version, ver
-from spack.package import PackageBase, run_after, InstallError
+from spack.build_environment import dso_suffix
+from spack.package import InstallError, PackageBase, run_after
from spack.util.environment import EnvironmentModifications
from spack.util.executable import Executable
from spack.util.prefix import Prefix
-from spack.build_environment import dso_suffix
+from spack.version import Version, ver
# A couple of utility functions that might be useful in general. If so, they
# should really be defined elsewhere, unless deemed heretical.
diff --git a/lib/spack/spack/build_systems/makefile.py b/lib/spack/spack/build_systems/makefile.py
index fbc415e0ed..45c1432dd4 100644
--- a/lib/spack/spack/build_systems/makefile.py
+++ b/lib/spack/spack/build_systems/makefile.py
@@ -9,6 +9,7 @@ from typing import List # novm
import llnl.util.tty as tty
from llnl.util.filesystem import working_dir
+
from spack.package import PackageBase, run_after
diff --git a/lib/spack/spack/build_systems/maven.py b/lib/spack/spack/build_systems/maven.py
index 7a5caabd29..5be6c763bd 100644
--- a/lib/spack/spack/build_systems/maven.py
+++ b/lib/spack/spack/build_systems/maven.py
@@ -5,6 +5,7 @@
from llnl.util.filesystem import install_tree, working_dir
+
from spack.directives import depends_on
from spack.package import PackageBase, run_after
from spack.util.executable import which
diff --git a/lib/spack/spack/build_systems/meson.py b/lib/spack/spack/build_systems/meson.py
index 3143ee8a43..21d703024f 100644
--- a/lib/spack/spack/build_systems/meson.py
+++ b/lib/spack/spack/build_systems/meson.py
@@ -9,6 +9,7 @@ import os
from typing import List # novm
from llnl.util.filesystem import working_dir
+
from spack.directives import depends_on, variant
from spack.package import PackageBase, run_after
diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py
index 41e337cb70..c429092cb6 100644
--- a/lib/spack/spack/build_systems/oneapi.py
+++ b/lib/spack/spack/build_systems/oneapi.py
@@ -8,16 +8,16 @@
"""
import getpass
-import shutil
import platform
+import shutil
from os.path import basename, dirname, isdir
+from llnl.util.filesystem import find_headers, find_libraries, join_path
+
from spack.package import Package
from spack.util.environment import EnvironmentModifications
from spack.util.executable import Executable
-from llnl.util.filesystem import find_headers, find_libraries, join_path
-
class IntelOneApiPackage(Package):
"""Base class for Intel oneAPI packages."""
diff --git a/lib/spack/spack/build_systems/perl.py b/lib/spack/spack/build_systems/perl.py
index a805c51176..56d9924994 100644
--- a/lib/spack/spack/build_systems/perl.py
+++ b/lib/spack/spack/build_systems/perl.py
@@ -7,10 +7,11 @@
import inspect
import os
+from llnl.util.filesystem import filter_file
+
from spack.directives import extends
from spack.package import PackageBase, run_after
from spack.util.executable import Executable
-from llnl.util.filesystem import filter_file
class PerlPackage(PackageBase):
diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py
index 696fb4aec9..b4f55ab707 100644
--- a/lib/spack/spack/build_systems/python.py
+++ b/lib/spack/spack/build_systems/python.py
@@ -6,14 +6,20 @@ import inspect
import os
import shutil
+import llnl.util.tty as tty
+from llnl.util.filesystem import (
+ filter_file,
+ find,
+ get_filetype,
+ path_contains_subdirectory,
+ same_path,
+ working_dir,
+)
+from llnl.util.lang import match_predicate
+
from spack.directives import extends
from spack.package import PackageBase, run_after
-from llnl.util.filesystem import (working_dir, get_filetype, filter_file,
- path_contains_subdirectory, same_path, find)
-from llnl.util.lang import match_predicate
-import llnl.util.tty as tty
-
class PythonPackage(PackageBase):
"""Specialized class for packages that are built using Python
diff --git a/lib/spack/spack/build_systems/qmake.py b/lib/spack/spack/build_systems/qmake.py
index 5ddb8d7fa3..0a7de9b433 100644
--- a/lib/spack/spack/build_systems/qmake.py
+++ b/lib/spack/spack/build_systems/qmake.py
@@ -7,6 +7,7 @@
import inspect
from llnl.util.filesystem import working_dir
+
from spack.directives import depends_on
from spack.package import PackageBase, run_after
diff --git a/lib/spack/spack/build_systems/rocm.py b/lib/spack/spack/build_systems/rocm.py
index 21a200e159..977db700db 100644
--- a/lib/spack/spack/build_systems/rocm.py
+++ b/lib/spack/spack/build_systems/rocm.py
@@ -75,10 +75,9 @@
# does not like its directory structure.
#
-from spack.package import PackageBase
-from spack.directives import depends_on, variant, conflicts
-
import spack.variant
+from spack.directives import conflicts, depends_on, variant
+from spack.package import PackageBase
class ROCmPackage(PackageBase):
diff --git a/lib/spack/spack/build_systems/sip.py b/lib/spack/spack/build_systems/sip.py
index 47713a100a..c32c46ec46 100644
--- a/lib/spack/spack/build_systems/sip.py
+++ b/lib/spack/spack/build_systems/sip.py
@@ -6,10 +6,11 @@
import inspect
import os
-from llnl.util.filesystem import find, working_dir, join_path
+import llnl.util.tty as tty
+from llnl.util.filesystem import find, join_path, working_dir
+
from spack.directives import depends_on, extends
from spack.package import PackageBase, run_after
-import llnl.util.tty as tty
class SIPPackage(PackageBase):
diff --git a/lib/spack/spack/build_systems/sourceforge.py b/lib/spack/spack/build_systems/sourceforge.py
index cfea664f51..4558408b2c 100644
--- a/lib/spack/spack/build_systems/sourceforge.py
+++ b/lib/spack/spack/build_systems/sourceforge.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import spack.util.url
import spack.package
+import spack.util.url
class SourceforgePackage(spack.package.PackageBase):
diff --git a/lib/spack/spack/build_systems/sourceware.py b/lib/spack/spack/build_systems/sourceware.py
index 89a157c22c..7e78054349 100644
--- a/lib/spack/spack/build_systems/sourceware.py
+++ b/lib/spack/spack/build_systems/sourceware.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import spack.util.url
import spack.package
+import spack.util.url
class SourcewarePackage(spack.package.PackageBase):
diff --git a/lib/spack/spack/build_systems/waf.py b/lib/spack/spack/build_systems/waf.py
index 99679ba64a..c33464b2a0 100644
--- a/lib/spack/spack/build_systems/waf.py
+++ b/lib/spack/spack/build_systems/waf.py
@@ -6,11 +6,11 @@
import inspect
+from llnl.util.filesystem import working_dir
+
from spack.directives import depends_on
from spack.package import PackageBase, run_after
-from llnl.util.filesystem import working_dir
-
class WafPackage(PackageBase):
"""Specialized class for packages that are built using the
diff --git a/lib/spack/spack/build_systems/xorg.py b/lib/spack/spack/build_systems/xorg.py
index 801ad37eeb..b27d875cec 100644
--- a/lib/spack/spack/build_systems/xorg.py
+++ b/lib/spack/spack/build_systems/xorg.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import spack.util.url
import spack.package
+import spack.util.url
class XorgPackage(spack.package.PackageBase):
diff --git a/lib/spack/spack/caches.py b/lib/spack/spack/caches.py
index 9f99ab75ed..67c93cb306 100644
--- a/lib/spack/spack/caches.py
+++ b/lib/spack/spack/caches.py
@@ -9,10 +9,10 @@ import os
import llnl.util.lang
from llnl.util.filesystem import mkdirp
-import spack.error
-import spack.paths
import spack.config
+import spack.error
import spack.fetch_strategy
+import spack.paths
import spack.util.file_cache
import spack.util.path
diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py
index 38b4de1c71..2ebbb842c5 100644
--- a/lib/spack/spack/ci.py
+++ b/lib/spack/spack/ci.py
@@ -21,6 +21,7 @@ from six.moves.urllib.request import HTTPHandler, Request, build_opener
import llnl.util.filesystem as fs
import llnl.util.tty as tty
+
import spack
import spack.binary_distribution as bindist
import spack.cmd
@@ -39,7 +40,6 @@ import spack.util.web as web_util
from spack.error import SpackError
from spack.spec import Spec
-
JOB_RETRY_CONDITIONS = [
'always',
]
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
index e9b4b60299..fc6b860350 100644
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -5,19 +5,20 @@
from __future__ import print_function
+import argparse
import os
import re
import sys
-import argparse
-import ruamel.yaml as yaml
+import ruamel.yaml as yaml
import six
+from ruamel.yaml.error import MarkedYAMLError
import llnl.util.tty as tty
+from llnl.util.filesystem import join_path
from llnl.util.lang import attr_setdefault, index_by
from llnl.util.tty.colify import colify
from llnl.util.tty.color import colorize
-from llnl.util.filesystem import join_path
import spack.config
import spack.error
@@ -27,8 +28,6 @@ import spack.spec
import spack.store
import spack.util.spack_json as sjson
import spack.util.string
-from ruamel.yaml.error import MarkedYAMLError
-
# cmd has a submodule called "list" so preserve the python list module
python_list = list
diff --git a/lib/spack/spack/cmd/add.py b/lib/spack/spack/cmd/add.py
index ae1a9c9b7e..453b9cd886 100644
--- a/lib/spack/spack/cmd/add.py
+++ b/lib/spack/spack/cmd/add.py
@@ -9,7 +9,6 @@ import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.environment as ev
-
description = 'add a spec to an environment'
section = "environments"
level = "long"
diff --git a/lib/spack/spack/cmd/analyze.py b/lib/spack/spack/cmd/analyze.py
index e32dbcd7b1..c2a6ec6a27 100644
--- a/lib/spack/spack/cmd/analyze.py
+++ b/lib/spack/spack/cmd/analyze.py
@@ -17,7 +17,6 @@ import spack.monitor
import spack.paths
import spack.report
-
description = "run analyzers on installed packages"
section = "analysis"
level = "long"
diff --git a/lib/spack/spack/cmd/arch.py b/lib/spack/spack/cmd/arch.py
index 7435fb1246..14be456e3f 100644
--- a/lib/spack/spack/cmd/arch.py
+++ b/lib/spack/spack/cmd/arch.py
@@ -8,8 +8,10 @@ from __future__ import print_function
import collections
import archspec.cpu
+
import llnl.util.tty.colify as colify
import llnl.util.tty.color as color
+
import spack.architecture as architecture
description = "print architecture information about this machine"
diff --git a/lib/spack/spack/cmd/audit.py b/lib/spack/spack/cmd/audit.py
index 09285258f7..67d761b7d8 100644
--- a/lib/spack/spack/cmd/audit.py
+++ b/lib/spack/spack/cmd/audit.py
@@ -3,10 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import llnl.util.tty.color as cl
+
import spack.audit
import spack.repo
-
description = "audit configuration files, packages, etc."
section = "system"
level = "short"
diff --git a/lib/spack/spack/cmd/blame.py b/lib/spack/spack/cmd/blame.py
index 0f11e73919..f0d71d838e 100644
--- a/lib/spack/spack/cmd/blame.py
+++ b/lib/spack/spack/cmd/blame.py
@@ -8,16 +8,15 @@ import re
import sys
import llnl.util.tty as tty
-from llnl.util.lang import pretty_date
from llnl.util.filesystem import working_dir
+from llnl.util.lang import pretty_date
from llnl.util.tty.colify import colify_table
-import spack.util.spack_json as sjson
import spack.paths
import spack.repo
-from spack.util.executable import which
+import spack.util.spack_json as sjson
from spack.cmd import spack_is_git_repo
-
+from spack.util.executable import which
description = "show contributors to packages"
section = "developer"
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index f5cb94e7c7..ebad6bb4b7 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -8,10 +8,12 @@ import shutil
import sys
import llnl.util.tty as tty
+
import spack.architecture
import spack.binary_distribution as bindist
import spack.cmd
import spack.cmd.common.arguments as arguments
+import spack.config
import spack.environment as ev
import spack.hash_types as ht
import spack.mirror
@@ -19,17 +21,12 @@ import spack.relocate
import spack.repo
import spack.spec
import spack.store
-import spack.config
-import spack.repo
-import spack.store
import spack.util.url as url_util
-
+from spack.cmd import display_specs
from spack.error import SpecError
from spack.spec import Spec, save_dependency_spec_yamls
from spack.util.string import plural
-from spack.cmd import display_specs
-
description = "create, download and install binary packages"
section = "packaging"
level = "long"
diff --git a/lib/spack/spack/cmd/checksum.py b/lib/spack/spack/cmd/checksum.py
index 937b054c27..5f27f9d174 100644
--- a/lib/spack/spack/cmd/checksum.py
+++ b/lib/spack/spack/cmd/checksum.py
@@ -15,7 +15,7 @@ import spack.repo
import spack.stage
import spack.util.crypto
from spack.util.naming import valid_fully_qualified_module_name
-from spack.version import ver, Version
+from spack.version import Version, ver
description = "checksum available versions of a package"
section = "packaging"
diff --git a/lib/spack/spack/cmd/ci.py b/lib/spack/spack/cmd/ci.py
index 804cd3ab80..64306ec8a7 100644
--- a/lib/spack/spack/cmd/ci.py
+++ b/lib/spack/spack/cmd/ci.py
@@ -14,6 +14,7 @@ import tempfile
from six.moves.urllib.parse import urlencode
import llnl.util.tty as tty
+
import spack.binary_distribution as bindist
import spack.ci as spack_ci
import spack.cmd.buildcache as buildcache
@@ -24,7 +25,6 @@ import spack.mirror
import spack.util.url as url_util
import spack.util.web as web_util
-
description = "manage continuous integration pipelines"
section = "build"
level = "long"
diff --git a/lib/spack/spack/cmd/clean.py b/lib/spack/spack/cmd/clean.py
index f82198abbe..273b1789ad 100644
--- a/lib/spack/spack/cmd/clean.py
+++ b/lib/spack/spack/cmd/clean.py
@@ -10,15 +10,14 @@ import shutil
import llnl.util.tty as tty
import spack.caches
-import spack.config
-import spack.cmd.test
import spack.cmd.common.arguments as arguments
+import spack.cmd.test
+import spack.config
import spack.main
import spack.repo
import spack.stage
from spack.paths import lib_path, var_path
-
description = "remove temporary build files and/or downloaded archives"
section = "build"
level = "long"
diff --git a/lib/spack/spack/cmd/commands.py b/lib/spack/spack/cmd/commands.py
index e63e162c3f..f58c0aab4b 100644
--- a/lib/spack/spack/cmd/commands.py
+++ b/lib/spack/spack/cmd/commands.py
@@ -14,7 +14,9 @@ import sys
import llnl.util.filesystem as fs
import llnl.util.tty as tty
from llnl.util.argparsewriter import (
- ArgparseWriter, ArgparseRstWriter, ArgparseCompletionWriter
+ ArgparseCompletionWriter,
+ ArgparseRstWriter,
+ ArgparseWriter,
)
from llnl.util.tty.colify import colify
@@ -23,7 +25,6 @@ import spack.main
import spack.paths
from spack.main import section_descriptions
-
description = "list available spack commands"
section = "developer"
level = "long"
diff --git a/lib/spack/spack/cmd/common/env_utility.py b/lib/spack/spack/cmd/common/env_utility.py
index b556d3edbc..29b402ff13 100644
--- a/lib/spack/spack/cmd/common/env_utility.py
+++ b/lib/spack/spack/cmd/common/env_utility.py
@@ -8,10 +8,11 @@ import argparse
import os
import llnl.util.tty as tty
+
import spack.build_environment as build_environment
-import spack.paths
import spack.cmd
import spack.cmd.common.arguments as arguments
+import spack.paths
from spack.util.environment import dump_environment, pickle_environment
diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py
index 08232022da..51d3dcced3 100644
--- a/lib/spack/spack/cmd/compiler.py
+++ b/lib/spack/spack/cmd/compiler.py
@@ -7,16 +7,18 @@ from __future__ import print_function
import argparse
import sys
+
from six import iteritems
import llnl.util.tty as tty
-import spack.compilers
-import spack.config
-import spack.spec
from llnl.util.lang import index_by
from llnl.util.tty.colify import colify
from llnl.util.tty.color import colorize
-from spack.spec import CompilerSpec, ArchSpec
+
+import spack.compilers
+import spack.config
+import spack.spec
+from spack.spec import ArchSpec, CompilerSpec
description = "manage compilers"
section = "system"
diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py
index 68ce8362fd..f1bdced6e0 100644
--- a/lib/spack/spack/cmd/config.py
+++ b/lib/spack/spack/cmd/config.py
@@ -10,15 +10,16 @@ import shutil
import llnl.util.filesystem as fs
import llnl.util.tty as tty
-import spack.config
+
import spack.cmd.common.arguments
-import spack.schema.env
+import spack.config
import spack.environment as ev
+import spack.repo
+import spack.schema.env
import spack.schema.packages
+import spack.store
import spack.util.spack_yaml as syaml
from spack.util.editor import editor
-import spack.store
-import spack.repo
description = "get and set configuration options"
section = "config"
diff --git a/lib/spack/spack/cmd/containerize.py b/lib/spack/spack/cmd/containerize.py
index a145558bd7..ea90b24b87 100644
--- a/lib/spack/spack/cmd/containerize.py
+++ b/lib/spack/spack/cmd/containerize.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import os.path
+
import spack.container
import spack.monitor
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index 85fea9d98a..a680848673 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -11,16 +11,23 @@ import re
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp
-import spack.util.web
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.util.editor import editor
-from spack.util.executable import which, ProcessError
-from spack.util.naming import mod_to_class
-from spack.util.naming import simplify_name, valid_fully_qualified_module_name
-from spack.url import UndetectableNameError, UndetectableVersionError
-from spack.url import parse_name, parse_version
+from spack.util.executable import ProcessError, which
+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/deprecate.py b/lib/spack/spack/cmd/deprecate.py
index 2928a5b264..2ab3cb17c8 100644
--- a/lib/spack/spack/cmd/deprecate.py
+++ b/lib/spack/spack/cmd/deprecate.py
@@ -14,18 +14,18 @@ It is up to the user to ensure binary compatibility between the deprecated
installation and its deprecator.
'''
from __future__ import print_function
+
import argparse
import os
import llnl.util.tty as tty
import spack.cmd
-import spack.store
import spack.cmd.common.arguments as arguments
import spack.environment as ev
-
-from spack.error import SpackError
+import spack.store
from spack.database import InstallStatuses
+from spack.error import SpackError
description = "Replace one package with another via symlinks"
section = "admin"
diff --git a/lib/spack/spack/cmd/dev_build.py b/lib/spack/spack/cmd/dev_build.py
index 2e7c51da42..24c416e105 100644
--- a/lib/spack/spack/cmd/dev_build.py
+++ b/lib/spack/spack/cmd/dev_build.py
@@ -3,14 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import sys
import os
+import sys
import llnl.util.tty as tty
-import spack.config
import spack.cmd
import spack.cmd.common.arguments as arguments
+import spack.config
import spack.repo
description = "developer build: build from code in current working directory"
diff --git a/lib/spack/spack/cmd/develop.py b/lib/spack/spack/cmd/develop.py
index d2dd8d0049..22bd6dad86 100644
--- a/lib/spack/spack/cmd/develop.py
+++ b/lib/spack/spack/cmd/develop.py
@@ -10,7 +10,6 @@ import llnl.util.tty as tty
import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.environment as ev
-
from spack.error import SpackError
description = "add a spec to an environment's dev-build information"
diff --git a/lib/spack/spack/cmd/edit.py b/lib/spack/spack/cmd/edit.py
index a277ed519e..30eb8d6fd6 100644
--- a/lib/spack/spack/cmd/edit.py
+++ b/lib/spack/spack/cmd/edit.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
import glob
+import os
import llnl.util.tty as tty
diff --git a/lib/spack/spack/cmd/env.py b/lib/spack/spack/cmd/env.py
index c980366352..64b9a2411d 100644
--- a/lib/spack/spack/cmd/env.py
+++ b/lib/spack/spack/cmd/env.py
@@ -8,22 +8,21 @@ import shutil
import sys
from collections import namedtuple
-import llnl.util.tty as tty
import llnl.util.filesystem as fs
+import llnl.util.tty as tty
from llnl.util.tty.colify import colify
from llnl.util.tty.color import colorize
-import spack.config
-import spack.schema.env
import spack.cmd.common.arguments
+import spack.cmd.common.arguments as arguments
import spack.cmd.install
-import spack.cmd.uninstall
import spack.cmd.modules
-import spack.cmd.common.arguments as arguments
+import spack.cmd.uninstall
+import spack.config
import spack.environment as ev
+import spack.schema.env
import spack.util.string as string
-
description = "manage virtual environments"
section = "environments"
level = "short"
diff --git a/lib/spack/spack/cmd/extensions.py b/lib/spack/spack/cmd/extensions.py
index a57aa031ff..d80eb84b60 100644
--- a/lib/spack/spack/cmd/extensions.py
+++ b/lib/spack/spack/cmd/extensions.py
@@ -9,9 +9,9 @@ import sys
import llnl.util.tty as tty
from llnl.util.tty.colify import colify
-import spack.environment as ev
import spack.cmd as cmd
import spack.cmd.common.arguments as arguments
+import spack.environment as ev
import spack.repo
import spack.store
from spack.filesystem_view import YamlFilesystemView
diff --git a/lib/spack/spack/cmd/external.py b/lib/spack/spack/cmd/external.py
index c7d045e66d..a57f9a58a4 100644
--- a/lib/spack/spack/cmd/external.py
+++ b/lib/spack/spack/cmd/external.py
@@ -10,10 +10,12 @@ import re
import sys
from collections import defaultdict, namedtuple
+import six
+
import llnl.util.filesystem
import llnl.util.tty as tty
import llnl.util.tty.colify as colify
-import six
+
import spack
import spack.cmd
import spack.cmd.common.arguments
diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py
index 21d4d01ce8..f532b684bd 100644
--- a/lib/spack/spack/cmd/find.py
+++ b/lib/spack/spack/cmd/find.py
@@ -9,17 +9,17 @@ import copy
import os
import sys
+import llnl.util.lang
import llnl.util.tty as tty
import llnl.util.tty.color as color
-import llnl.util.lang
-import spack.environment as ev
-import spack.repo
import spack.cmd as cmd
import spack.cmd.common.arguments as arguments
+import spack.environment as ev
+import spack.repo
import spack.user_environment as uenv
-from spack.util.string import plural
from spack.database import InstallStatuses
+from spack.util.string import plural
description = "list and search installed packages"
section = "basic"
diff --git a/lib/spack/spack/cmd/flake8.py b/lib/spack/spack/cmd/flake8.py
index 7da059ba69..0579cb674a 100644
--- a/lib/spack/spack/cmd/flake8.py
+++ b/lib/spack/spack/cmd/flake8.py
@@ -9,7 +9,6 @@ import llnl.util.tty as tty
import spack.cmd.style
-
description = "alias for spack style (deprecated)"
section = spack.cmd.style.section
level = spack.cmd.style.level
diff --git a/lib/spack/spack/cmd/gpg.py b/lib/spack/spack/cmd/gpg.py
index 3a65f1abc3..ffe178aa91 100644
--- a/lib/spack/spack/cmd/gpg.py
+++ b/lib/spack/spack/cmd/gpg.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
import argparse
+import os
import spack.binary_distribution
import spack.cmd.common.arguments as arguments
diff --git a/lib/spack/spack/cmd/graph.py b/lib/spack/spack/cmd/graph.py
index 3d962a52f8..c7675f1ada 100644
--- a/lib/spack/spack/cmd/graph.py
+++ b/lib/spack/spack/cmd/graph.py
@@ -11,7 +11,7 @@ import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.config
import spack.store
-from spack.graph import graph_dot, graph_ascii
+from spack.graph import graph_ascii, 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 bc289c0363..0055c33719 100644
--- a/lib/spack/spack/cmd/help.py
+++ b/lib/spack/spack/cmd/help.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
+
from llnl.util.tty.color import colorize
description = "get help on spack and its commands"
diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py
index c3e5a51903..f244bc4854 100644
--- a/lib/spack/spack/cmd/info.py
+++ b/lib/spack/spack/cmd/info.py
@@ -6,6 +6,7 @@
from __future__ import print_function
import textwrap
+
from six.moves import zip_longest
import llnl.util.tty as tty
@@ -13,10 +14,9 @@ import llnl.util.tty.color as color
from llnl.util.tty.colify import colify
import spack.cmd.common.arguments as arguments
+import spack.fetch_strategy as fs
import spack.repo
import spack.spec
-import spack.fetch_strategy as fs
-
description = 'get detailed information on a particular package'
section = 'basic'
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index 4f3b3222e4..5a452a9232 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -23,7 +23,6 @@ import spack.report
from spack.error import SpackError
from spack.installer import PackageInstaller
-
description = "build and install packages"
section = "build"
level = "short"
diff --git a/lib/spack/spack/cmd/list.py b/lib/spack/spack/cmd/list.py
index c00e7a903d..80f7e7a287 100644
--- a/lib/spack/spack/cmd/list.py
+++ b/lib/spack/spack/cmd/list.py
@@ -3,23 +3,22 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from __future__ import print_function
-from __future__ import division
+from __future__ import division, print_function
import argparse
import fnmatch
+import json
+import math
import os
import re
import sys
-import math
-import json
import llnl.util.tty as tty
from llnl.util.tty.colify import colify
+import spack.cmd.common.arguments as arguments
import spack.dependency
import spack.repo
-import spack.cmd.common.arguments as arguments
from spack.version import VersionList
if sys.version_info > (3, 1):
diff --git a/lib/spack/spack/cmd/load.py b/lib/spack/spack/cmd/load.py
index df0d56c444..6749e169fa 100644
--- a/lib/spack/spack/cmd/load.py
+++ b/lib/spack/spack/cmd/load.py
@@ -8,9 +8,9 @@ import sys
import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.environment as ev
-import spack.util.environment
-import spack.user_environment as uenv
import spack.store
+import spack.user_environment as uenv
+import spack.util.environment
description = "add package to the user environment"
section = "user environment"
diff --git a/lib/spack/spack/cmd/location.py b/lib/spack/spack/cmd/location.py
index 9c63881be3..61687f02bc 100644
--- a/lib/spack/spack/cmd/location.py
+++ b/lib/spack/spack/cmd/location.py
@@ -6,12 +6,13 @@
from __future__ import print_function
import os
+
import llnl.util.tty as tty
-import spack.environment as ev
import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.environment
+import spack.environment as ev
import spack.paths
import spack.repo
import spack.stage
diff --git a/lib/spack/spack/cmd/log_parse.py b/lib/spack/spack/cmd/log_parse.py
index 4f7fd119c0..64c034ae25 100644
--- a/lib/spack/spack/cmd/log_parse.py
+++ b/lib/spack/spack/cmd/log_parse.py
@@ -6,7 +6,8 @@
import sys
import llnl.util.tty as tty
-from spack.util.log_parse import parse_log_events, make_log_context
+
+from spack.util.log_parse import make_log_context, parse_log_events
description = "filter errors and warnings from build logs"
section = "build"
diff --git a/lib/spack/spack/cmd/maintainers.py b/lib/spack/spack/cmd/maintainers.py
index 9813103704..18d294da0d 100644
--- a/lib/spack/spack/cmd/maintainers.py
+++ b/lib/spack/spack/cmd/maintainers.py
@@ -12,7 +12,6 @@ import llnl.util.tty as tty
import llnl.util.tty.color as color
from llnl.util.tty.colify import colify
-
import spack.repo
description = "get information about package maintainers"
diff --git a/lib/spack/spack/cmd/mark.py b/lib/spack/spack/cmd/mark.py
index 96c041ba72..3dfd075312 100644
--- a/lib/spack/spack/cmd/mark.py
+++ b/lib/spack/spack/cmd/mark.py
@@ -7,16 +7,16 @@ from __future__ import print_function
import sys
+from llnl.util import tty
+
import spack.cmd
+import spack.cmd.common.arguments as arguments
import spack.error
import spack.package
-import spack.cmd.common.arguments as arguments
import spack.repo
import spack.store
from spack.database import InstallStatuses
-from llnl.util import tty
-
description = "mark packages as explicitly or implicitly installed"
section = "admin"
level = "long"
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 508ddff543..84d7fa0649 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -17,9 +17,8 @@ import spack.mirror
import spack.repo
import spack.util.url as url_util
import spack.util.web as web_util
-
-from spack.spec import Spec
from spack.error import SpackError
+from spack.spec import Spec
from spack.util.spack_yaml import syaml_dict
description = "manage mirrors (source and binary)"
diff --git a/lib/spack/spack/cmd/module.py b/lib/spack/spack/cmd/module.py
index e0fd0ab44f..a03df1b787 100644
--- a/lib/spack/spack/cmd/module.py
+++ b/lib/spack/spack/cmd/module.py
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import argparse
-from typing import Dict, Callable # novm
+from typing import Callable, Dict # novm
import llnl.util.tty as tty
diff --git a/lib/spack/spack/cmd/modules/__init__.py b/lib/spack/spack/cmd/modules/__init__.py
index 3d6975801f..2098e67b73 100644
--- a/lib/spack/spack/cmd/modules/__init__.py
+++ b/lib/spack/spack/cmd/modules/__init__.py
@@ -13,12 +13,11 @@ import sys
from llnl.util import filesystem, tty
import spack.cmd
+import spack.cmd.common.arguments as arguments
import spack.config
import spack.modules
-import spack.repo
import spack.modules.common
-
-import spack.cmd.common.arguments as arguments
+import spack.repo
description = "manipulate module files"
section = "environment"
diff --git a/lib/spack/spack/cmd/modules/lmod.py b/lib/spack/spack/cmd/modules/lmod.py
index 3546e2b87a..d28ccb3eaf 100644
--- a/lib/spack/spack/cmd/modules/lmod.py
+++ b/lib/spack/spack/cmd/modules/lmod.py
@@ -7,6 +7,7 @@ import functools
import os
import llnl.util.filesystem
+
import spack.cmd.common.arguments
import spack.cmd.modules
diff --git a/lib/spack/spack/cmd/monitor.py b/lib/spack/spack/cmd/monitor.py
index aec40bbd6a..90371f446f 100644
--- a/lib/spack/spack/cmd/monitor.py
+++ b/lib/spack/spack/cmd/monitor.py
@@ -5,7 +5,6 @@
import spack.monitor
-
description = "interact with a monitor server"
section = "analysis"
level = "long"
diff --git a/lib/spack/spack/cmd/patch.py b/lib/spack/spack/cmd/patch.py
index 14739b8d7d..bc1ef10afb 100644
--- a/lib/spack/spack/cmd/patch.py
+++ b/lib/spack/spack/cmd/patch.py
@@ -5,10 +5,9 @@
import llnl.util.tty as tty
-import spack.repo
import spack.cmd
import spack.cmd.common.arguments as arguments
-
+import spack.repo
description = "patch expanded archive sources in preparation for install"
section = "build"
diff --git a/lib/spack/spack/cmd/pkg.py b/lib/spack/spack/cmd/pkg.py
index f7e3523ff4..8440cbd82c 100644
--- a/lib/spack/spack/cmd/pkg.py
+++ b/lib/spack/spack/cmd/pkg.py
@@ -9,8 +9,8 @@ import os
import re
import llnl.util.tty as tty
-from llnl.util.tty.colify import colify
from llnl.util.filesystem import working_dir
+from llnl.util.tty.colify import colify
import spack.cmd
import spack.cmd.common.arguments as arguments
diff --git a/lib/spack/spack/cmd/providers.py b/lib/spack/spack/cmd/providers.py
index 5effdacf8c..0faeb41bdd 100644
--- a/lib/spack/spack/cmd/providers.py
+++ b/lib/spack/spack/cmd/providers.py
@@ -3,9 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import six
import sys
+import six
+
import llnl.util.tty.colify as colify
import spack.cmd
diff --git a/lib/spack/spack/cmd/python.py b/lib/spack/spack/cmd/python.py
index 5cee319ff5..156e01b4ba 100644
--- a/lib/spack/spack/cmd/python.py
+++ b/lib/spack/spack/cmd/python.py
@@ -5,12 +5,12 @@
from __future__ import print_function
-import os
-import sys
-import code
import argparse
+import code
+import os
import platform
import runpy
+import sys
import llnl.util.tty as tty
diff --git a/lib/spack/spack/cmd/remove.py b/lib/spack/spack/cmd/remove.py
index 376d73b687..1f97e6e6e5 100644
--- a/lib/spack/spack/cmd/remove.py
+++ b/lib/spack/spack/cmd/remove.py
@@ -9,7 +9,6 @@ import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.environment as ev
-
description = 'remove specs from an environment'
section = "environments"
level = "long"
diff --git a/lib/spack/spack/cmd/repo.py b/lib/spack/spack/cmd/repo.py
index 3930a03d0f..250f57dcd7 100644
--- a/lib/spack/spack/cmd/repo.py
+++ b/lib/spack/spack/cmd/repo.py
@@ -8,6 +8,7 @@ from __future__ import print_function
import os
import llnl.util.tty as tty
+
import spack.config
import spack.repo
import spack.util.path
diff --git a/lib/spack/spack/cmd/resource.py b/lib/spack/spack/cmd/resource.py
index ed9e7982fa..6d39991b42 100644
--- a/lib/spack/spack/cmd/resource.py
+++ b/lib/spack/spack/cmd/resource.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from __future__ import print_function
+
import os
import llnl.util.tty as tty
@@ -11,7 +12,6 @@ import llnl.util.tty.color as color
import spack.repo
-
description = "list downloadable resources (tarballs, repos, patches, etc.)"
section = "basic"
level = "long"
diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py
index 3a66a05f0b..592da60388 100644
--- a/lib/spack/spack/cmd/spec.py
+++ b/lib/spack/spack/cmd/spec.py
@@ -13,9 +13,9 @@ import llnl.util.tty as tty
import spack
import spack.cmd
import spack.cmd.common.arguments as arguments
+import spack.hash_types as ht
import spack.spec
import spack.store
-import spack.hash_types as ht
description = "show what would be installed, given a spec"
section = "build"
diff --git a/lib/spack/spack/cmd/stage.py b/lib/spack/spack/cmd/stage.py
index 9e41f1b005..c3a3c21e68 100644
--- a/lib/spack/spack/cmd/stage.py
+++ b/lib/spack/spack/cmd/stage.py
@@ -7,10 +7,10 @@ import os
import llnl.util.tty as tty
-import spack.environment as ev
-import spack.repo
import spack.cmd
import spack.cmd.common.arguments as arguments
+import spack.environment as ev
+import spack.repo
import spack.stage
description = "expand downloaded archive in preparation for install"
diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py
index 343c019bce..c480b4394f 100644
--- a/lib/spack/spack/cmd/test.py
+++ b/lib/spack/spack/cmd/test.py
@@ -4,22 +4,23 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from __future__ import print_function
-import os
+
import argparse
-import textwrap
-import inspect
import fnmatch
+import inspect
+import os
import re
import shutil
import sys
+import textwrap
import llnl.util.tty as tty
import llnl.util.tty.colify as colify
-import spack.install_test
-import spack.environment as ev
import spack.cmd
import spack.cmd.common.arguments as arguments
+import spack.environment as ev
+import spack.install_test
import spack.package
import spack.repo
import spack.report
diff --git a/lib/spack/spack/cmd/tutorial.py b/lib/spack/spack/cmd/tutorial.py
index 1f6c573731..e45d75b6f3 100644
--- a/lib/spack/spack/cmd/tutorial.py
+++ b/lib/spack/spack/cmd/tutorial.py
@@ -18,7 +18,6 @@ import spack.util.gpg
from spack.util.executable import which
from spack.util.spack_yaml import syaml_dict
-
description = "set up spack for our tutorial (WARNING: modifies config!)"
section = "config"
level = "long"
diff --git a/lib/spack/spack/cmd/undevelop.py b/lib/spack/spack/cmd/undevelop.py
index 09fe558d56..3f8288e09a 100644
--- a/lib/spack/spack/cmd/undevelop.py
+++ b/lib/spack/spack/cmd/undevelop.py
@@ -9,7 +9,6 @@ import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.environment as ev
-
description = 'remove specs from an environment'
section = "environments"
level = "long"
diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py
index 2a9e6b00b7..9d787a70a2 100644
--- a/lib/spack/spack/cmd/uninstall.py
+++ b/lib/spack/spack/cmd/uninstall.py
@@ -5,21 +5,21 @@
from __future__ import print_function
-import sys
import itertools
+import sys
+
+from llnl.util import tty
+from llnl.util.tty.colify import colify
import spack.cmd
+import spack.cmd.common.arguments as arguments
import spack.environment as ev
import spack.error
import spack.package
-import spack.cmd.common.arguments as arguments
import spack.repo
import spack.store
from spack.database import InstallStatuses
-from llnl.util import tty
-from llnl.util.tty.colify import colify
-
description = "remove installed packages"
section = "build"
level = "short"
diff --git a/lib/spack/spack/cmd/unit_test.py b/lib/spack/spack/cmd/unit_test.py
index c290bc8572..ce4e2cbdbb 100644
--- a/lib/spack/spack/cmd/unit_test.py
+++ b/lib/spack/spack/cmd/unit_test.py
@@ -3,13 +3,13 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from __future__ import print_function
-from __future__ import division
+from __future__ import division, print_function
+import argparse
import collections
-import sys
import re
-import argparse
+import sys
+
import pytest
from six import StringIO
diff --git a/lib/spack/spack/cmd/unload.py b/lib/spack/spack/cmd/unload.py
index c854466e05..f1e10ba05a 100644
--- a/lib/spack/spack/cmd/unload.py
+++ b/lib/spack/spack/cmd/unload.py
@@ -3,14 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import sys
import os
+import sys
import spack.cmd
import spack.cmd.common.arguments as arguments
-import spack.util.environment
-import spack.user_environment as uenv
import spack.error
+import spack.user_environment as uenv
+import spack.util.environment
description = "remove package from the user environment"
section = "user environment"
diff --git a/lib/spack/spack/cmd/url.py b/lib/spack/spack/cmd/url.py
index e5dde5e9c7..1576a4f762 100644
--- a/lib/spack/spack/cmd/url.py
+++ b/lib/spack/spack/cmd/url.py
@@ -4,22 +4,30 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from __future__ import division, print_function
+
from collections import defaultdict
import six.moves.urllib.parse as urllib_parse
+from llnl.util import tty
+
import spack.fetch_strategy as fs
import spack.repo
import spack.util.crypto as crypto
-
-from llnl.util import tty
-from spack.url import parse_version_offset, parse_name_offset
-from spack.url import parse_name, parse_version, color_url
-from spack.url import substitute_version, substitution_offsets
-from spack.url import UndetectableNameError, UndetectableVersionError
-from spack.url import UrlParseError
-from spack.util.web import find_versions_of_archive
+from spack.url import (
+ UndetectableNameError,
+ UndetectableVersionError,
+ UrlParseError,
+ color_url,
+ parse_name,
+ parse_name_offset,
+ parse_version,
+ parse_version_offset,
+ substitute_version,
+ substitution_offsets,
+)
from spack.util.naming import simplify_name
+from spack.util.web import find_versions_of_archive
description = "debugging tool for url parsing"
section = "developer"
diff --git a/lib/spack/spack/cmd/verify.py b/lib/spack/spack/cmd/verify.py
index 6e7ff0f3bd..723aa2f994 100644
--- a/lib/spack/spack/cmd/verify.py
+++ b/lib/spack/spack/cmd/verify.py
@@ -3,13 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from __future__ import print_function
+
import argparse
import llnl.util.tty as tty
+import spack.environment as ev
import spack.store
import spack.verify
-import spack.environment as ev
description = "Check that all spack packages are on disk as installed"
section = "admin"
diff --git a/lib/spack/spack/cmd/versions.py b/lib/spack/spack/cmd/versions.py
index ec808e0e89..8e9da05fe9 100644
--- a/lib/spack/spack/cmd/versions.py
+++ b/lib/spack/spack/cmd/versions.py
@@ -7,12 +7,12 @@ from __future__ import print_function
import sys
-from llnl.util.tty.colify import colify
import llnl.util.tty as tty
+from llnl.util.tty.colify import colify
import spack.cmd.common.arguments as arguments
import spack.repo
-from spack.version import ver, infinity_versions
+from spack.version import infinity_versions, ver
description = "list available versions of a package"
section = "packaging"
diff --git a/lib/spack/spack/cmd/view.py b/lib/spack/spack/cmd/view.py
index ec8003bbf7..7c745a4da0 100644
--- a/lib/spack/spack/cmd/view.py
+++ b/lib/spack/spack/cmd/view.py
@@ -37,13 +37,17 @@ import llnl.util.tty as tty
from llnl.util.link_tree import MergeConflictError
from llnl.util.tty.color import colorize
-import spack.environment as ev
import spack.cmd
-import spack.store
+import spack.environment as ev
import spack.schema.projections
+import spack.store
from spack.config import validate
-from spack.filesystem_view import YamlFilesystemView
-from spack.filesystem_view import view_symlink, view_hardlink, view_copy
+from spack.filesystem_view import (
+ YamlFilesystemView,
+ view_copy,
+ view_hardlink,
+ view_symlink,
+)
from spack.util import spack_yaml as s_yaml
description = "project packages to a compact naming scheme on the filesystem."
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index 684f21e2d8..d3410bba2d 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -4,26 +4,25 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import contextlib
+import itertools
import os
import platform
import re
-import itertools
import shutil
import tempfile
-from typing import Sequence, List # novm
+from typing import List, Sequence # novm
import llnl.util.lang
-from llnl.util.filesystem import (
- path_contains_subdirectory, paths_containing_libs)
import llnl.util.tty as tty
+from llnl.util.filesystem import path_contains_subdirectory, paths_containing_libs
+import spack.architecture
+import spack.compilers
import spack.error
import spack.spec
-import spack.version
-import spack.architecture
import spack.util.executable
import spack.util.module_cmd
-import spack.compilers
+import spack.version
from spack.util.environment import filter_system_paths
__all__ = ['Compiler']
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 817d21add6..537e8211c3 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -10,21 +10,22 @@ import collections
import itertools
import multiprocessing.pool
import os
-import six
from typing import Dict # novm
-import llnl.util.lang
+import six
+
+import archspec.cpu
+
import llnl.util.filesystem as fs
+import llnl.util.lang
import llnl.util.tty as tty
-import archspec.cpu
-import spack.paths
+import spack.architecture
+import spack.compiler
+import spack.config
import spack.error
+import spack.paths
import spack.spec
-import spack.config
-import spack.compiler
-import spack.architecture
-
from spack.util.environment import get_path
from spack.util.naming import mod_to_class
diff --git a/lib/spack/spack/compilers/apple_clang.py b/lib/spack/spack/compilers/apple_clang.py
index 372a677a47..83cf0a15cd 100644
--- a/lib/spack/spack/compilers/apple_clang.py
+++ b/lib/spack/spack/compilers/apple_clang.py
@@ -6,8 +6,9 @@ import os.path
import re
import shutil
-import llnl.util.tty as tty
import llnl.util.lang
+import llnl.util.tty as tty
+
import spack.compiler
import spack.compilers.clang
import spack.util.executable
diff --git a/lib/spack/spack/compilers/arm.py b/lib/spack/spack/compilers/arm.py
index 4c59d89210..f742623c6b 100644
--- a/lib/spack/spack/compilers/arm.py
+++ b/lib/spack/spack/compilers/arm.py
@@ -3,9 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import spack.compiler
import re
+import spack.compiler
+
class Arm(spack.compiler.Compiler):
# Subclasses use possible names of C compiler
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index d2dc3db192..6935301979 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -11,7 +11,6 @@ import llnl.util.lang
from spack.compiler import Compiler, UnsupportedCompilerFlag
from spack.version import ver
-
#: compiler symlink mappings for mixed f77 compilers
f77_mapping = [
('gfortran', 'clang/gfortran'),
diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py
index ff8675324e..5047de3a0b 100644
--- a/lib/spack/spack/compilers/gcc.py
+++ b/lib/spack/spack/compilers/gcc.py
@@ -7,7 +7,6 @@ import re
import spack.compiler
import spack.compilers.apple_clang as apple_clang
-
from spack.version import ver
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 81af96504a..1048709297 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -16,33 +16,31 @@ TODO: make this customizable and allow users to configure
"""
from __future__ import print_function
-import platform
import os.path
+import platform
import tempfile
+from contextlib import contextmanager
+from itertools import chain
+
+from functools_backport import reverse_order
import archspec.cpu
import llnl.util.filesystem as fs
-import llnl.util.tty as tty
-
-from itertools import chain
-from functools_backport import reverse_order
-from contextlib import contextmanager
-
import llnl.util.lang
+import llnl.util.tty as tty
-import spack.repo
import spack.abi
-import spack.spec
-import spack.compilers
import spack.architecture
+import spack.compilers
import spack.error
+import spack.repo
+import spack.spec
import spack.tengine
import spack.variant as vt
from spack.config import config
-from spack.version import ver, Version, VersionList, VersionRange
-from spack.package_prefs import PackagePrefs, spec_externals, is_spec_buildable
-
+from spack.package_prefs import PackagePrefs, is_spec_buildable, spec_externals
+from spack.version import Version, VersionList, VersionRange, ver
#: impements rudimentary logic for ABI compatibility
_abi = llnl.util.lang.Singleton(lambda: spack.abi.ABI())
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index 420a432fe9..038a879a81 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -36,34 +36,34 @@ import os
import re
import sys
from contextlib import contextmanager
-from six import iteritems
-from ordereddict_backport import OrderedDict
from typing import List # novm
import ruamel.yaml as yaml
+from ordereddict_backport import OrderedDict
from ruamel.yaml.error import MarkedYAMLError
+from six import iteritems
import llnl.util.lang
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp
-import spack.paths
import spack.architecture
import spack.compilers
+import spack.paths
import spack.schema
import spack.schema.compilers
+import spack.schema.config
+import spack.schema.env
import spack.schema.mirrors
-import spack.schema.repos
-import spack.schema.packages
import spack.schema.modules
-import spack.schema.config
+import spack.schema.packages
+import spack.schema.repos
import spack.schema.upstreams
-import spack.schema.env
-from spack.error import SpackError
-from spack.util.cpus import cpus_available
# Hacked yaml for configuration files preserves line numbers.
import spack.util.spack_yaml as syaml
+from spack.error import SpackError
+from spack.util.cpus import cpus_available
#: Dict from section names -> schema for that section
section_schemas = {
@@ -935,6 +935,7 @@ def validate(data, schema, filename=None):
on Spack YAML structures.
"""
import jsonschema
+
# validate a copy to avoid adding defaults
# This allows us to round-trip data without adding to it.
test_data = copy.deepcopy(data)
diff --git a/lib/spack/spack/container/__init__.py b/lib/spack/spack/container/__init__.py
index 7211f94ff1..c57e0d0c51 100644
--- a/lib/spack/spack/container/__init__.py
+++ b/lib/spack/spack/container/__init__.py
@@ -10,6 +10,7 @@ import warnings
import spack.environment
import spack.schema.env as env
import spack.util.spack_yaml as syaml
+
from .writers import recipe
__all__ = ['validate', 'recipe']
diff --git a/lib/spack/spack/container/writers/__init__.py b/lib/spack/spack/container/writers/__init__.py
index 4c43e3db35..14bc5a77c4 100644
--- a/lib/spack/spack/container/writers/__init__.py
+++ b/lib/spack/spack/container/writers/__init__.py
@@ -12,9 +12,7 @@ import spack.environment
import spack.schema.env
import spack.tengine as tengine
import spack.util.spack_yaml as syaml
-
-from spack.container.images import build_info, commands_for
-from spack.container.images import os_package_manager_for
+from spack.container.images import build_info, commands_for, os_package_manager_for
#: Caches all the writers that are currently supported
_writer_factory = {}
@@ -135,6 +133,7 @@ class PathContext(tengine.Context):
def manifest(self):
"""The spack.yaml file that should be used in the image"""
import jsonschema
+
# Copy in the part of spack.yaml prescribed in the configuration file
manifest = copy.deepcopy(self.config)
manifest.pop('container')
diff --git a/lib/spack/spack/container/writers/docker.py b/lib/spack/spack/container/writers/docker.py
index 7c9372fb86..218b11727c 100644
--- a/lib/spack/spack/container/writers/docker.py
+++ b/lib/spack/spack/container/writers/docker.py
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.tengine as tengine
-from . import writer, PathContext
+from . import PathContext, writer
@writer('docker')
diff --git a/lib/spack/spack/container/writers/singularity.py b/lib/spack/spack/container/writers/singularity.py
index e3eaaea008..f40449ad2d 100644
--- a/lib/spack/spack/container/writers/singularity.py
+++ b/lib/spack/spack/container/writers/singularity.py
@@ -3,7 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.tengine as tengine
-from . import writer, PathContext
+
+from . import PathContext, writer
@writer('singularity')
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py
index d998895fed..60e93ed49b 100644
--- a/lib/spack/spack/database.py
+++ b/lib/spack/spack/database.py
@@ -39,6 +39,7 @@ except ImportError:
import llnl.util.filesystem as fs
import llnl.util.tty as tty
+
import spack.repo
import spack.spec
import spack.store
diff --git a/lib/spack/spack/dependency.py b/lib/spack/spack/dependency.py
index 0773ce0763..a798915980 100644
--- a/lib/spack/spack/dependency.py
+++ b/lib/spack/spack/dependency.py
@@ -9,7 +9,6 @@ from six import string_types
import spack.spec
-
#: The types of dependency relationships that Spack understands.
all_deptypes = ('build', 'link', 'run', 'test')
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index f9cdc261d3..d9195d9ecd 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -37,6 +37,7 @@ import six
import llnl.util.lang
import llnl.util.tty.color
+
import spack.error
import spack.patch
import spack.spec
@@ -47,7 +48,6 @@ from spack.fetch_strategy import from_kwargs
from spack.resource import Resource
from spack.version import Version, VersionChecksumError
-
if sys.version_info >= (3, 3):
from collections.abc import Sequence # novm
else:
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index 8a429a850f..1634f3dab4 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -3,11 +3,11 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import errno
+import glob
import os
import shutil
-import glob
import tempfile
-import errno
from contextlib import contextmanager
import ruamel.yaml as yaml
@@ -20,7 +20,6 @@ import spack.spec
import spack.util.spack_json as sjson
from spack.error import SpackError
-
default_projections = {'all': ('{architecture}/'
'{compiler.name}-{compiler.version}/'
'{name}-{version}-{hash}')}
@@ -327,8 +326,7 @@ class YamlDirectoryLayout(DirectoryLayout):
# Create install directory with properly configured permissions
# Cannot import at top of file
- from spack.package_prefs import get_package_dir_permissions
- from spack.package_prefs import get_package_group
+ from spack.package_prefs import get_package_dir_permissions, get_package_group
# Each package folder can have its own specific permissions, while
# intermediate folders (arch/compiler) are set with access permissions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index 15921c5389..c41d567bce 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -3,14 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import collections
+import copy
import os
import re
-import sys
import shutil
-import copy
-import six
-import ruamel.yaml as yaml
+import sys
+import ruamel.yaml as yaml
+import six
from ordereddict_backport import OrderedDict
import llnl.util.filesystem as fs
@@ -18,27 +18,27 @@ import llnl.util.tty as tty
from llnl.util.tty.color import colorize
import spack.concretize
+import spack.config
import spack.error
import spack.hash_types as ht
import spack.hooks
import spack.repo
import spack.schema.env
import spack.spec
-import spack.store
import spack.stage
-import spack.util.spack_json as sjson
-import spack.util.spack_yaml as syaml
-import spack.config
+import spack.store
import spack.user_environment as uenv
-from spack.filesystem_view import YamlFilesystemView
import spack.util.environment
-from spack.spec import Spec
-from spack.spec_list import SpecList, InvalidSpecConstraintError
-from spack.variant import UnknownVariantError
import spack.util.hash
import spack.util.lock as lk
-from spack.util.path import substitute_path_variables
import spack.util.path
+import spack.util.spack_json as sjson
+import spack.util.spack_yaml as syaml
+from spack.filesystem_view import YamlFilesystemView
+from spack.spec import Spec
+from spack.spec_list import InvalidSpecConstraintError, SpecList
+from spack.util.path import substitute_path_variables
+from spack.variant import UnknownVariantError
#: environment variable used to indicate the active environment
spack_env_var = 'SPACK_ENV'
diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py
index fa66a35b0e..f0283e27c1 100644
--- a/lib/spack/spack/error.py
+++ b/lib/spack/spack/error.py
@@ -5,12 +5,11 @@
from __future__ import print_function
-import sys
import inspect
+import sys
import llnl.util.tty as tty
-
#: whether we should write stack traces or short error messages
#: this is module-scoped because it needs to be set very early
debug = False
diff --git a/lib/spack/spack/extensions.py b/lib/spack/spack/extensions.py
index 9ea7373b8c..69a287fe85 100644
--- a/lib/spack/spack/extensions.py
+++ b/lib/spack/spack/extensions.py
@@ -11,6 +11,7 @@ import sys
import types
import llnl.util.lang
+
import spack.config
import spack.error
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 3b98fac143..3eee59349e 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -35,14 +35,20 @@ import six
import six.moves.urllib.parse as urllib_parse
import llnl.util.tty as tty
+from llnl.util.filesystem import (
+ get_single_file,
+ mkdirp,
+ temp_cwd,
+ temp_rename,
+ working_dir,
+)
+
import spack.config
import spack.error
import spack.util.crypto as crypto
import spack.util.pattern as pattern
import spack.util.url as url_util
import spack.util.web as web_util
-from llnl.util.filesystem import (
- get_single_file, mkdirp, temp_cwd, temp_rename, working_dir)
from spack.util.compression import decompressor_for, extension
from spack.util.executable import CommandNotFoundError, which
from spack.util.string import comma_and, quote
diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py
index 232223b69f..dd872d712f 100644
--- a/lib/spack/spack/filesystem_view.py
+++ b/lib/spack/spack/filesystem_view.py
@@ -8,33 +8,33 @@ import os
import re
import shutil
import sys
+
from ordereddict_backport import OrderedDict
-from llnl.util.link_tree import LinkTree, MergeConflictError
from llnl.util import tty
-from llnl.util.lang import match_predicate, index_by
+from llnl.util.filesystem import mkdirp, remove_dead_links, remove_empty_directories
+from llnl.util.lang import index_by, match_predicate
+from llnl.util.link_tree import LinkTree, MergeConflictError
from llnl.util.tty.color import colorize
-from llnl.util.filesystem import (
- mkdirp, remove_dead_links, remove_empty_directories)
-
-import spack.util.spack_yaml as s_yaml
-import spack.util.spack_json as s_json
-import spack.spec
-import spack.store
-import spack.schema.projections
-import spack.projections
import spack.config
+import spack.projections
import spack.relocate
+import spack.schema.projections
+import spack.spec
+import spack.store
+import spack.util.spack_json as s_json
+import spack.util.spack_yaml as s_yaml
+from spack.directory_layout import (
+ ExtensionAlreadyInstalledError,
+ YamlViewExtensionsLayout,
+)
from spack.error import SpackError
-from spack.directory_layout import ExtensionAlreadyInstalledError
-from spack.directory_layout import YamlViewExtensionsLayout
-
# compatability
if sys.version_info < (3, 0):
- from itertools import imap as map
from itertools import ifilter as filter
+ from itertools import imap as map
from itertools import izip as zip
__all__ = ["FilesystemView", "YamlFilesystemView"]
diff --git a/lib/spack/spack/graph.py b/lib/spack/spack/graph.py
index 87ad51e030..7ca7b11af7 100644
--- a/lib/spack/spack/graph.py
+++ b/lib/spack/spack/graph.py
@@ -49,7 +49,6 @@ from llnl.util.tty.color import ColorStream
from spack.dependency import all_deptypes, canonical_deptype
-
__all__ = ['topological_sort', 'graph_ascii', 'AsciiGraph', 'graph_dot']
diff --git a/lib/spack/spack/hooks/__init__.py b/lib/spack/spack/hooks/__init__.py
index d4b8cd8eca..e802fa0197 100644
--- a/lib/spack/spack/hooks/__init__.py
+++ b/lib/spack/spack/hooks/__init__.py
@@ -29,6 +29,7 @@ systems (e.g. modules, lmod, etc.) or to add other custom
features.
"""
import llnl.util.lang
+
import spack.paths
diff --git a/lib/spack/spack/hooks/module_file_generation.py b/lib/spack/spack/hooks/module_file_generation.py
index 2007a77af7..b95040aed2 100644
--- a/lib/spack/spack/hooks/module_file_generation.py
+++ b/lib/spack/spack/hooks/module_file_generation.py
@@ -3,10 +3,11 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import llnl.util.tty as tty
+
import spack.config
import spack.modules
import spack.modules.common
-import llnl.util.tty as tty
def _for_each_enabled(spec, method_name):
diff --git a/lib/spack/spack/hooks/monitor.py b/lib/spack/spack/hooks/monitor.py
index 8d161b72fa..5ddc1223e8 100644
--- a/lib/spack/spack/hooks/monitor.py
+++ b/lib/spack/spack/hooks/monitor.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import llnl.util.tty as tty
+
import spack.monitor
diff --git a/lib/spack/spack/hooks/permissions_setters.py b/lib/spack/spack/hooks/permissions_setters.py
index d640018515..e09876d3fd 100644
--- a/lib/spack/spack/hooks/permissions_setters.py
+++ b/lib/spack/spack/hooks/permissions_setters.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import spack.util.file_permissions as fp
diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py
index 7dc00165d5..b6e088e921 100644
--- a/lib/spack/spack/hooks/sbang.py
+++ b/lib/spack/spack/hooks/sbang.py
@@ -5,12 +5,12 @@
import filecmp
import os
-import stat
import re
+import stat
import sys
-import llnl.util.tty as tty
import llnl.util.filesystem as fs
+import llnl.util.tty as tty
import spack.modules
import spack.paths
diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py
index cf832e9f4d..9142bb448c 100644
--- a/lib/spack/spack/install_test.py
+++ b/lib/spack/spack/install_test.py
@@ -12,12 +12,10 @@ import tty
import llnl.util.filesystem as fs
-from spack.spec import Spec
-
import spack.error
import spack.util.prefix
import spack.util.spack_json as sjson
-
+from spack.spec import Spec
test_suite_filename = 'test_suite.lock'
results_filename = 'results.txt'
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index 6e812959f9..c6eebf3041 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -39,10 +39,12 @@ from collections import defaultdict
import six
-
import llnl.util.filesystem as fs
import llnl.util.lock as lk
import llnl.util.tty as tty
+from llnl.util.tty.color import colorize
+from llnl.util.tty.log import log_output
+
import spack.binary_distribution as binary_distribution
import spack.compilers
import spack.error
@@ -52,8 +54,6 @@ import spack.package
import spack.package_prefs as prefs
import spack.repo
import spack.store
-from llnl.util.tty.color import colorize
-from llnl.util.tty.log import log_output
from spack.util.environment import dump_environment
from spack.util.executable import which
from spack.util.timer import Timer
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index c088f068f6..ea65ab99df 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -21,12 +21,15 @@ import sys
import traceback
import warnings
-import archspec.cpu
from six import StringIO
+import archspec.cpu
+
import llnl.util.filesystem as fs
import llnl.util.tty as tty
import llnl.util.tty.color as color
+from llnl.util.tty.log import log_output
+
import spack
import spack.architecture
import spack.cmd
@@ -39,7 +42,6 @@ import spack.store
import spack.util.debug
import spack.util.executable as exe
import spack.util.path
-from llnl.util.tty.log import log_output
from spack.error import SpackError
#: names of profile statistics
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 283cff47d5..a4ec57ab5b 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -11,16 +11,14 @@ the main server for a particular package is down. Or, if the computer
where spack is run is not connected to the internet, it allows spack
to download packages directly from a mirror (e.g., on an intranet).
"""
-import sys
+import operator
import os
-import traceback
import os.path
-import operator
-
-import six
+import sys
+import traceback
import ruamel.yaml.error as yaml_error
-
+import six
from ordereddict_backport import OrderedDict
if sys.version_info >= (3, 5):
@@ -33,14 +31,14 @@ from llnl.util.filesystem import mkdirp
import spack.config
import spack.error
-import spack.url as url
import spack.fetch_strategy as fs
+import spack.spec
+import spack.url as url
import spack.util.spack_json as sjson
import spack.util.spack_yaml as syaml
import spack.util.url as url_util
-import spack.spec
-from spack.version import VersionList
from spack.util.spack_yaml import syaml_dict
+from spack.version import VersionList
def _display_mirror_entry(size, name, url, type_=None):
diff --git a/lib/spack/spack/mixins.py b/lib/spack/spack/mixins.py
index ee1f57c91d..596aabebec 100644
--- a/lib/spack/spack/mixins.py
+++ b/lib/spack/spack/mixins.py
@@ -10,6 +10,7 @@ import collections
import os
import sys
from typing import Callable, DefaultDict, Dict, List # novm
+
if sys.version_info >= (3, 5):
CallbackDict = DefaultDict[str, List[Callable]]
else:
diff --git a/lib/spack/spack/modules/__init__.py b/lib/spack/spack/modules/__init__.py
index b65260277f..7a85c94430 100644
--- a/lib/spack/spack/modules/__init__.py
+++ b/lib/spack/spack/modules/__init__.py
@@ -9,8 +9,8 @@ include TCL non-hierarchical modules, LUA hierarchical modules, and others.
from __future__ import absolute_import
-from .tcl import TclModulefileWriter
from .lmod import LmodModulefileWriter
+from .tcl import TclModulefileWriter
__all__ = [
'TclModulefileWriter',
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index bb89487750..5d9ea36648 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -37,14 +37,15 @@ import re
from typing import Optional # novm
import llnl.util.filesystem
-from llnl.util.lang import dedupe
import llnl.util.tty as tty
+from llnl.util.lang import dedupe
+
import spack.build_environment as build_environment
import spack.environment as ev
import spack.error
import spack.paths
-import spack.schema.environment
import spack.projections as proj
+import spack.schema.environment
import spack.tengine as tengine
import spack.util.environment
import spack.util.file_permissions as fp
diff --git a/lib/spack/spack/modules/lmod.py b/lib/spack/spack/modules/lmod.py
index bc47761421..38b1dd1705 100644
--- a/lib/spack/spack/modules/lmod.py
+++ b/lib/spack/spack/modules/lmod.py
@@ -3,22 +3,21 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import collections
+import itertools
import os.path
+from typing import Any, Dict # novm
import llnl.util.lang as lang
-import itertools
-import collections
-from typing import Dict, Any # novm
-import spack.config
import spack.compilers
-import spack.spec
-import spack.repo
+import spack.config
import spack.error
+import spack.repo
+import spack.spec
import spack.tengine as tengine
-from .common import BaseConfiguration, BaseFileLayout
-from .common import BaseContext, BaseModuleFileWriter
+from .common import BaseConfiguration, BaseContext, BaseFileLayout, BaseModuleFileWriter
#: lmod specific part of the configuration
diff --git a/lib/spack/spack/modules/tcl.py b/lib/spack/spack/modules/tcl.py
index d2f980bbc7..8b5e823e5e 100644
--- a/lib/spack/spack/modules/tcl.py
+++ b/lib/spack/spack/modules/tcl.py
@@ -8,15 +8,15 @@ non-hierarchical modules.
"""
import os.path
import string
-from typing import Dict, Any # novm
+from typing import Any, Dict # novm
import llnl.util.tty as tty
import spack.config
import spack.projections as proj
import spack.tengine as tengine
-from .common import BaseConfiguration, BaseFileLayout
-from .common import BaseContext, BaseModuleFileWriter
+
+from .common import BaseConfiguration, BaseContext, BaseFileLayout, BaseModuleFileWriter
#: TCL specific part of the configuration
diff --git a/lib/spack/spack/monitor.py b/lib/spack/spack/monitor.py
index 1b44d0a032..b75836b3d2 100644
--- a/lib/spack/spack/monitor.py
+++ b/lib/spack/spack/monitor.py
@@ -7,29 +7,31 @@
https://github.com/spack/spack-monitor/blob/main/script/spackmoncli.py
"""
-from datetime import datetime
-import hashlib
import base64
+import hashlib
import os
import re
+from datetime import datetime
try:
- from urllib.request import Request, urlopen
from urllib.error import URLError
+ from urllib.request import Request, urlopen
except ImportError:
from urllib2 import urlopen, Request, URLError # type: ignore # novm
+from copy import deepcopy
+from glob import glob
+
+import llnl.util.tty as tty
+
import spack
import spack.config
import spack.hash_types as ht
import spack.main
import spack.store
+import spack.util.path
import spack.util.spack_json as sjson
import spack.util.spack_yaml as syaml
-import spack.util.path
-import llnl.util.tty as tty
-from copy import deepcopy
-from glob import glob
# A global client to instantiate once
cli = None
diff --git a/lib/spack/spack/multimethod.py b/lib/spack/spack/multimethod.py
index 6ffc50f5d4..7fa4c42065 100644
--- a/lib/spack/spack/multimethod.py
+++ b/lib/spack/spack/multimethod.py
@@ -27,9 +27,10 @@ so package authors should use their judgement.
import functools
import inspect
+from llnl.util.lang import caller_locals
+
import spack.directives
import spack.error
-from llnl.util.lang import caller_locals
from spack.spec import Spec
diff --git a/lib/spack/spack/operating_systems/linux_distro.py b/lib/spack/spack/operating_systems/linux_distro.py
index b1901fc41c..fe9c00d55f 100644
--- a/lib/spack/spack/operating_systems/linux_distro.py
+++ b/lib/spack/spack/operating_systems/linux_distro.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
+
from spack.architecture import OperatingSystem
diff --git a/lib/spack/spack/operating_systems/mac_os.py b/lib/spack/spack/operating_systems/mac_os.py
index 0d5bc6cfe9..180b2e6ac0 100644
--- a/lib/spack/spack/operating_systems/mac_os.py
+++ b/lib/spack/spack/operating_systems/mac_os.py
@@ -6,8 +6,8 @@
import platform as py_platform
from spack.architecture import OperatingSystem
-from spack.version import Version
from spack.util.executable import Executable
+from spack.version import Version
# FIXME: store versions inside OperatingSystem as a Version instead of string
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index bf37018c4d..e3299b3bdc 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -33,6 +33,9 @@ from ordereddict_backport import OrderedDict
import llnl.util.filesystem as fsys
import llnl.util.tty as tty
+from llnl.util.lang import memoized
+from llnl.util.link_tree import LinkTree
+
import spack.compilers
import spack.config
import spack.dependency
@@ -50,8 +53,6 @@ import spack.store
import spack.url
import spack.util.environment
import spack.util.web
-from llnl.util.lang import memoized
-from llnl.util.link_tree import LinkTree
from spack.filesystem_view import YamlFilesystemView
from spack.install_test import TestFailure, TestSuite
from spack.installer import InstallError, PackageInstaller
@@ -1833,6 +1834,7 @@ class PackageBase(six.with_metaclass(PackageMeta, PackageViewMixin, object)):
exc_type, _, tb = sys.exc_info()
print('FAILED: {0}'.format(e))
import traceback
+
# remove the current call frame to exclude the extract_stack
# call from the error
stack = traceback.extract_stack()[:-1]
diff --git a/lib/spack/spack/package_prefs.py b/lib/spack/spack/package_prefs.py
index cf74c7ee52..f242956493 100644
--- a/lib/spack/spack/package_prefs.py
+++ b/lib/spack/spack/package_prefs.py
@@ -6,11 +6,11 @@ import stat
from six import string_types
-import spack.repo
import spack.error
+import spack.repo
+from spack.config import ConfigError
from spack.util.path import canonicalize_path
from spack.version import VersionList
-from spack.config import ConfigError
_lesser_spec_types = {'compiler': spack.spec.CompilerSpec,
'version': VersionList}
@@ -159,7 +159,7 @@ def spec_externals(spec):
"""Return a list of external specs (w/external directory path filled in),
one for each known external installation."""
# break circular import.
- from spack.util.module_cmd import path_from_modules # NOQA: ignore=F401
+ from spack.util.module_cmd import path_from_modules # NOQA: ignore=F401
allpkgs = spack.config.get('packages')
names = set([spec.name])
diff --git a/lib/spack/spack/package_test.py b/lib/spack/spack/package_test.py
index 6a4df096fc..16518fa316 100644
--- a/lib/spack/spack/package_test.py
+++ b/lib/spack/spack/package_test.py
@@ -4,7 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
-from spack.util.executable import which, Executable
+
+from spack.util.executable import Executable, which
def compile_c_and_execute(source_file, include_flags, link_flags):
diff --git a/lib/spack/spack/parse.py b/lib/spack/spack/parse.py
index 1fc853bee4..a5d550961f 100644
--- a/lib/spack/spack/parse.py
+++ b/lib/spack/spack/parse.py
@@ -3,10 +3,11 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import itertools
import re
import shlex
import sys
-import itertools
+
from six import string_types
import spack.error
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py
index 8eb7b8146f..68691554f4 100644
--- a/lib/spack/spack/patch.py
+++ b/lib/spack/spack/patch.py
@@ -4,22 +4,21 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import hashlib
+import inspect
import os
import os.path
-import inspect
import llnl.util.filesystem
import llnl.util.lang
+import spack
import spack.error
import spack.fetch_strategy as fs
import spack.repo
import spack.stage
import spack.util.spack_json as sjson
-import spack
-
from spack.util.compression import allowed_archive
-from spack.util.crypto import checksum, Checker
+from spack.util.crypto import Checker, checksum
from spack.util.executable import which
diff --git a/lib/spack/spack/paths.py b/lib/spack/spack/paths.py
index c45a5a6b0f..6b41049de8 100644
--- a/lib/spack/spack/paths.py
+++ b/lib/spack/spack/paths.py
@@ -10,6 +10,7 @@ throughout Spack and should bring in a minimal number of external
dependencies.
"""
import os
+
from llnl.util.filesystem import ancestor
#: This file lives in $prefix/lib/spack/spack/__file__
diff --git a/lib/spack/spack/pkgkit.py b/lib/spack/spack/pkgkit.py
index bc44d0b7b2..fc056f14ad 100644
--- a/lib/spack/spack/pkgkit.py
+++ b/lib/spack/spack/pkgkit.py
@@ -11,62 +11,62 @@ Everything in this module is automatically imported into Spack package files.
import llnl.util.filesystem
from llnl.util.filesystem import *
-from spack.package import \
- Package, BundlePackage, \
- run_before, run_after, on_package_attributes
-from spack.package import inject_flags, env_flags, build_system_flags
-from spack.build_systems.makefile import MakefilePackage
+import spack.directives
+import spack.util.executable
from spack.build_systems.aspell_dict import AspellDictPackage
from spack.build_systems.autotools import AutotoolsPackage
-from spack.build_systems.cmake import CMakePackage
from spack.build_systems.cached_cmake import (
- CachedCMakePackage, cmake_cache_option, cmake_cache_path,
- cmake_cache_string
+ CachedCMakePackage,
+ cmake_cache_option,
+ cmake_cache_path,
+ cmake_cache_string,
)
+from spack.build_systems.cmake import CMakePackage
from spack.build_systems.cuda import CudaPackage
-from spack.build_systems.oneapi import IntelOneApiPackage
-from spack.build_systems.oneapi import IntelOneApiLibraryPackage
-from spack.build_systems.rocm import ROCmPackage
-from spack.build_systems.qmake import QMakePackage
+from spack.build_systems.gnu import GNUMirrorPackage
+from spack.build_systems.intel import IntelPackage
+from spack.build_systems.makefile import MakefilePackage
from spack.build_systems.maven import MavenPackage
-from spack.build_systems.scons import SConsPackage
-from spack.build_systems.waf import WafPackage
+from spack.build_systems.meson import MesonPackage
from spack.build_systems.octave import OctavePackage
+from spack.build_systems.oneapi import IntelOneApiLibraryPackage, IntelOneApiPackage
+from spack.build_systems.perl import PerlPackage
from spack.build_systems.python import PythonPackage
+from spack.build_systems.qmake import QMakePackage
from spack.build_systems.r import RPackage
-from spack.build_systems.perl import PerlPackage
+from spack.build_systems.rocm import ROCmPackage
from spack.build_systems.ruby import RubyPackage
-from spack.build_systems.intel import IntelPackage
-from spack.build_systems.meson import MesonPackage
+from spack.build_systems.scons import SConsPackage
from spack.build_systems.sip import SIPPackage
-from spack.build_systems.gnu import GNUMirrorPackage
from spack.build_systems.sourceforge import SourceforgePackage
from spack.build_systems.sourceware import SourcewarePackage
+from spack.build_systems.waf import WafPackage
from spack.build_systems.xorg import XorgPackage
-
-from spack.mixins import filter_compiler_wrappers
-
-from spack.version import Version, ver
-
-from spack.spec import Spec, InvalidSpecDetected
-
from spack.dependency import all_deptypes
-
-from spack.multimethod import when
-
-import spack.directives
from spack.directives import *
-
-import spack.util.executable
-from spack.util.executable import *
-
-from spack.package import \
- install_dependency_symlinks, flatten_dependencies, \
- DependencyConflictError
-
-from spack.installer import \
- ExternalPackageError, InstallError, InstallLockError, UpstreamPackageError
from spack.install_test import get_escaped_text_output
-
-from spack.variant import any_combination_of, auto_or_any_combination_of
-from spack.variant import disjoint_sets
+from spack.installer import (
+ ExternalPackageError,
+ InstallError,
+ InstallLockError,
+ UpstreamPackageError,
+)
+from spack.mixins import filter_compiler_wrappers
+from spack.multimethod import when
+from spack.package import (
+ BundlePackage,
+ DependencyConflictError,
+ Package,
+ build_system_flags,
+ env_flags,
+ flatten_dependencies,
+ inject_flags,
+ install_dependency_symlinks,
+ on_package_attributes,
+ run_after,
+ run_before,
+)
+from spack.spec import InvalidSpecDetected, Spec
+from spack.util.executable import *
+from spack.variant import any_combination_of, auto_or_any_combination_of, disjoint_sets
+from spack.version import Version, ver
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 5eb0ee9310..85c66fd92f 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -4,20 +4,20 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import os.path
-import re
import platform
+import re
import archspec.cpu
import llnl.util.tty as tty
+
+from spack.architecture import NoPlatformError, Platform, Target
+from spack.operating_systems.cray_backend import CrayBackend
+from spack.operating_systems.cray_frontend import CrayFrontend
from spack.paths import build_env_path
from spack.util.executable import Executable
-from spack.architecture import Platform, Target, NoPlatformError
-from spack.operating_systems.cray_frontend import CrayFrontend
-from spack.operating_systems.cray_backend import CrayBackend
from spack.util.module_cmd import module
-
_craype_name_to_target_name = {
'x86-cascadelake': 'cascadelake',
'x86-naples': 'zen',
diff --git a/lib/spack/spack/platforms/test.py b/lib/spack/spack/platforms/test.py
index 80d9431879..9333bb3262 100644
--- a/lib/spack/spack/platforms/test.py
+++ b/lib/spack/spack/platforms/test.py
@@ -4,8 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import platform
-from spack.architecture import Platform, Target
-from spack.architecture import OperatingSystem
+
+from spack.architecture import OperatingSystem, Platform, Target
class Test(Platform):
diff --git a/lib/spack/spack/provider_index.py b/lib/spack/spack/provider_index.py
index 6a84d8f40a..39ab3f7145 100644
--- a/lib/spack/spack/provider_index.py
+++ b/lib/spack/spack/provider_index.py
@@ -6,6 +6,7 @@
import itertools
import six
+
import spack.error
import spack.util.spack_json as sjson
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index e167472b75..ef1d2e9456 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -2,17 +2,19 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import multiprocessing.pool
import os
import platform
import re
import shutil
-import multiprocessing.pool
+
+import macholib.mach_o
+import macholib.MachO
from ordereddict_backport import OrderedDict
import llnl.util.lang
import llnl.util.tty as tty
-import macholib.MachO
-import macholib.mach_o
+
import spack.architecture
import spack.cmd
import spack.repo
diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py
index 61f5e1d28c..706fe40dd2 100644
--- a/lib/spack/spack/repo.py
+++ b/lib/spack/spack/repo.py
@@ -13,13 +13,14 @@ import itertools
import os
import re
import shutil
-import six
import stat
import sys
import traceback
import types
from typing import Dict # novm
+import six
+
if sys.version_info >= (3, 5):
from collections.abc import Mapping # novm
else:
@@ -27,19 +28,20 @@ else:
import ruamel.yaml as yaml
+import llnl.util.filesystem as fs
import llnl.util.lang
import llnl.util.tty as tty
-import llnl.util.filesystem as fs
-import spack.config
+
import spack.caches
+import spack.config
import spack.error
import spack.patch
+import spack.provider_index
import spack.spec
-import spack.util.spack_json as sjson
import spack.util.imp as simp
-import spack.provider_index
-import spack.util.path
import spack.util.naming as nm
+import spack.util.path
+import spack.util.spack_json as sjson
#: Super-namespace for all packages.
#: Package modules are imported as spack.pkg.<namespace>.<pkg-name>.
diff --git a/lib/spack/spack/report.py b/lib/spack/spack/report.py
index 8e97d036c0..4685321bc8 100644
--- a/lib/spack/spack/report.py
+++ b/lib/spack/spack/report.py
@@ -7,11 +7,12 @@
import codecs
import collections
import functools
+import os
import time
import traceback
-import os
import llnl.util.lang
+
import spack.build_environment
import spack.fetch_strategy
import spack.package
diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py
index 36660fa890..24e4f2833a 100644
--- a/lib/spack/spack/reporters/cdash.py
+++ b/lib/spack/spack/reporters/cdash.py
@@ -12,13 +12,15 @@ import re
import socket
import time
import xml.sax.saxutils
+
+from ordereddict_backport import OrderedDict
from six import iteritems, text_type
-from six.moves.urllib.request import build_opener, HTTPHandler, Request
from six.moves.urllib.parse import urlencode
+from six.moves.urllib.request import HTTPHandler, Request, build_opener
-from llnl.util.filesystem import working_dir
import llnl.util.tty as tty
-from ordereddict_backport import OrderedDict
+from llnl.util.filesystem import working_dir
+
import spack.build_environment
import spack.fetch_strategy
import spack.package
diff --git a/lib/spack/spack/s3_handler.py b/lib/spack/spack/s3_handler.py
index d906577bed..8f9322716a 100644
--- a/lib/spack/spack/s3_handler.py
+++ b/lib/spack/spack/s3_handler.py
@@ -5,9 +5,9 @@
from io import BufferedReader
-import six.moves.urllib.response as urllib_response
-import six.moves.urllib.request as urllib_request
import six.moves.urllib.error as urllib_error
+import six.moves.urllib.request as urllib_request
+import six.moves.urllib.response as urllib_response
import spack.util.s3 as s3_util
import spack.util.url as url_util
diff --git a/lib/spack/spack/schema/__init__.py b/lib/spack/spack/schema/__init__.py
index 804b7c989d..0b584cf07b 100644
--- a/lib/spack/spack/schema/__init__.py
+++ b/lib/spack/spack/schema/__init__.py
@@ -8,6 +8,7 @@ import six
import llnl.util.lang
import llnl.util.tty
+
import spack.spec
diff --git a/lib/spack/spack/schema/buildcache_spec.py b/lib/spack/spack/schema/buildcache_spec.py
index f1c515852c..6f4acac9a9 100644
--- a/lib/spack/spack/schema/buildcache_spec.py
+++ b/lib/spack/spack/schema/buildcache_spec.py
@@ -10,7 +10,6 @@
"""
import spack.schema.spec
-
schema = {
'$schema': 'http://json-schema.org/schema#',
'title': 'Spack buildcache spec.yaml schema',
diff --git a/lib/spack/spack/schema/config.py b/lib/spack/spack/schema/config.py
index f0669600e1..1df922b137 100644
--- a/lib/spack/spack/schema/config.py
+++ b/lib/spack/spack/schema/config.py
@@ -9,7 +9,9 @@
:lines: 13-
"""
import six
+
from llnl.util.lang import union_dicts
+
import spack.schema.projections
#: Properties for inclusion in other schemas
diff --git a/lib/spack/spack/schema/environment.py b/lib/spack/spack/schema/environment.py
index 6431916c56..3e1c0b3c3f 100644
--- a/lib/spack/spack/schema/environment.py
+++ b/lib/spack/spack/schema/environment.py
@@ -39,6 +39,7 @@ def parse(config_obj):
schema definition for environment modifications
"""
import sys
+
import spack.util.environment as ev
if sys.version_info >= (3, 5):
from collections.abc import Sequence # novm
diff --git a/lib/spack/spack/schema/merged.py b/lib/spack/spack/schema/merged.py
index a58f47cb16..9555f7b194 100644
--- a/lib/spack/spack/schema/merged.py
+++ b/lib/spack/spack/schema/merged.py
@@ -21,7 +21,6 @@ import spack.schema.packages
import spack.schema.repos
import spack.schema.upstreams
-
#: Properties for inclusion in other schemas
properties = union_dicts(
spack.schema.cdash.properties,
diff --git a/lib/spack/spack/schema/packages.py b/lib/spack/spack/schema/packages.py
index e24f610c74..86aabc6649 100644
--- a/lib/spack/spack/schema/packages.py
+++ b/lib/spack/spack/schema/packages.py
@@ -22,8 +22,11 @@ def deprecate_paths_and_modules(instance, deprecated_properties):
"""
import copy
import os.path
+
import llnl.util.tty
+
import spack.util.spack_yaml as syaml
+
# Copy the instance to remove default attributes that are not related
# to the part that needs to be reported
instance_copy = copy.copy(instance)
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 55573518de..bb83fd4b5c 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -12,12 +12,14 @@ import pprint
import sys
import types
import warnings
+
from six import string_types
import archspec.cpu
try:
import clingo
+
# There may be a better way to detect this
clingo_cffi = hasattr(clingo.Symbol, '_rep')
except ImportError:
@@ -29,20 +31,20 @@ import llnl.util.tty as tty
import spack
import spack.architecture
+import spack.bootstrap
import spack.cmd
import spack.compilers
import spack.config
import spack.dependency
import spack.directives
import spack.error
-import spack.spec
import spack.package
import spack.package_prefs
import spack.repo
-import spack.bootstrap
+import spack.spec
+import spack.util.timer
import spack.variant
import spack.version
-import spack.util.timer
if sys.version_info >= (3, 3):
from collections.abc import Sequence # novm
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 609b20e238..7a69dad881 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -76,30 +76,30 @@ thing. Spack uses ~variant in directory names and in the canonical form of
specs to avoid ambiguity. Both are provided because ~ can cause shell
expansion when it is the first character in an id typed on the command line.
"""
-import sys
import collections
import itertools
import operator
import os
import re
+import sys
-import six
import ruamel.yaml as yaml
+import six
import llnl.util.filesystem as fs
import llnl.util.lang as lang
-import llnl.util.tty.color as clr
import llnl.util.tty as tty
+import llnl.util.tty.color as clr
-import spack.paths
import spack.architecture
import spack.compiler
-import spack.compilers as compilers
+import spack.compilers
import spack.config
import spack.dependency as dp
import spack.error
import spack.hash_types as ht
import spack.parse
+import spack.paths
import spack.provider_index
import spack.repo
import spack.solver
@@ -115,7 +115,6 @@ import spack.util.string
import spack.variant as vt
import spack.version as vn
-
if sys.version_info >= (3, 3):
from collections.abc import Mapping # novm
else:
@@ -2967,7 +2966,7 @@ class Spec(object):
# validate compiler in addition to the package name.
if spec.compiler:
- if not compilers.supported(spec.compiler):
+ if not spack.compilers.supported(spec.compiler):
raise UnsupportedCompilerError(spec.compiler.name)
# Ensure correctness of variants (if the spec is not virtual)
diff --git a/lib/spack/spack/spec_list.py b/lib/spack/spack/spec_list.py
index 4f7ae79ed9..e7b12e0996 100644
--- a/lib/spack/spack/spec_list.py
+++ b/lib/spack/spack/spec_list.py
@@ -3,11 +3,12 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import itertools
+
from six import string_types
import spack.variant
-from spack.spec import Spec
from spack.error import SpackError
+from spack.spec import Spec
def spec_ordering_key(s):
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 1bcf644eb5..1ca2ed5637 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -14,28 +14,32 @@ import shutil
import stat
import sys
import tempfile
-from six import string_types
-from six import iteritems
from typing import Dict # novm
+from six import iteritems, string_types
+
import llnl.util.tty as tty
-from llnl.util.filesystem import mkdirp, can_access, install, install_tree
-from llnl.util.filesystem import partition_path, remove_linked_tree
+from llnl.util.filesystem import (
+ can_access,
+ install,
+ install_tree,
+ mkdirp,
+ partition_path,
+ remove_linked_tree,
+)
-import spack.paths
import spack.caches
import spack.cmd
import spack.config
import spack.error
+import spack.fetch_strategy as fs
import spack.mirror
+import spack.paths
import spack.util.lock
-import spack.fetch_strategy as fs
-import spack.util.pattern as pattern
import spack.util.path as sup
+import spack.util.pattern as pattern
import spack.util.url as url_util
-
-from spack.util.crypto import prefix_bits, bit_length
-
+from spack.util.crypto import bit_length, prefix_bits
# The well-known stage source subdirectory name.
_source_path_subdir = 'spack-src'
diff --git a/lib/spack/spack/store.py b/lib/spack/spack/store.py
index 5d05349b2d..4fcd96cdd8 100644
--- a/lib/spack/spack/store.py
+++ b/lib/spack/spack/store.py
@@ -26,17 +26,17 @@ configuration.
import contextlib
import os
import re
+
import six
import llnl.util.lang
import llnl.util.tty as tty
-import spack.paths
import spack.config
-import spack.util.path
import spack.database
import spack.directory_layout
-
+import spack.paths
+import spack.util.path
#: default installation root, relative to the Spack install path
default_install_tree_root = os.path.join(spack.paths.opt_path, 'spack')
diff --git a/lib/spack/spack/subprocess_context.py b/lib/spack/spack/subprocess_context.py
index 0b41d796fa..803411cb95 100644
--- a/lib/spack/spack/subprocess_context.py
+++ b/lib/spack/spack/subprocess_context.py
@@ -13,18 +13,16 @@ modifications to global state in memory that must be replicated in the
child process.
"""
-from types import ModuleType
-
+import io
+import multiprocessing
import pickle
import pydoc
-import io
import sys
-import multiprocessing
+from types import ModuleType
import spack.architecture
import spack.config
-
_serialize = sys.version_info >= (3, 8) and sys.platform == 'darwin'
diff --git a/lib/spack/spack/tengine.py b/lib/spack/spack/tengine.py
index fc2f19f57f..7748555689 100644
--- a/lib/spack/spack/tengine.py
+++ b/lib/spack/spack/tengine.py
@@ -6,9 +6,10 @@ import itertools
import textwrap
from typing import List # novm
-import llnl.util.lang
import six
+import llnl.util.lang
+
import spack.config
from spack.util.path import canonicalize_path
diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py
index e37818f10c..12e70cff47 100644
--- a/lib/spack/spack/test/architecture.py
+++ b/lib/spack/spack/test/architecture.py
@@ -14,10 +14,10 @@ import pytest
import spack.architecture
import spack.concretize
-from spack.spec import Spec
from spack.platforms.cray import Cray
-from spack.platforms.linux import Linux
from spack.platforms.darwin import Darwin
+from spack.platforms.linux import Linux
+from spack.spec import Spec
def test_dict_functions_for_architecture():
diff --git a/lib/spack/spack/test/bindist.py b/lib/spack/spack/test/bindist.py
index d7e4ddb50f..2e6d599422 100644
--- a/lib/spack/spack/test/bindist.py
+++ b/lib/spack/spack/test/bindist.py
@@ -4,8 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
import os
-import sys
import platform
+import sys
import py
import pytest
@@ -19,7 +19,6 @@ import spack.repo
import spack.store
import spack.util.gpg
import spack.util.web as web_util
-
from spack.directory_layout import YamlDirectoryLayout
from spack.spec import Spec
diff --git a/lib/spack/spack/test/build_distribution.py b/lib/spack/spack/test/build_distribution.py
index 873a57a0e9..da8797221a 100644
--- a/lib/spack/spack/test/build_distribution.py
+++ b/lib/spack/spack/test/build_distribution.py
@@ -3,13 +3,13 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
-
import os
import os.path
-import spack.spec
+import pytest
+
import spack.binary_distribution
+import spack.spec
install = spack.main.SpackCommand('install')
diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py
index a179dda650..b745eb228b 100644
--- a/lib/spack/spack/test/build_environment.py
+++ b/lib/spack/spack/test/build_environment.py
@@ -8,16 +8,20 @@ import platform
import pytest
+from llnl.util.filesystem import HeaderList, LibraryList
+
import spack.build_environment
import spack.config
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.paths import build_env_path
-from spack.build_environment import dso_suffix, _static_to_shared_library
-from spack.build_environment import determine_number_of_jobs
-from spack.util.executable import Executable
from spack.util.environment import EnvironmentModifications
-from llnl.util.filesystem import LibraryList, HeaderList
+from spack.util.executable import Executable
@pytest.fixture
diff --git a/lib/spack/spack/test/build_system_guess.py b/lib/spack/spack/test/build_system_guess.py
index ab9735fd48..2d3487cb7a 100644
--- a/lib/spack/spack/test/build_system_guess.py
+++ b/lib/spack/spack/test/build_system_guess.py
@@ -5,9 +5,10 @@
import pytest
+
import spack.cmd.create
-import spack.util.executable
import spack.stage
+import spack.util.executable
@pytest.fixture(
diff --git a/lib/spack/spack/test/build_systems.py b/lib/spack/spack/test/build_systems.py
index b02da380a8..28e470da8c 100644
--- a/lib/spack/spack/test/build_systems.py
+++ b/lib/spack/spack/test/build_systems.py
@@ -5,15 +5,16 @@
import glob
import os
+
import pytest
import llnl.util.filesystem as fs
+
import spack.repo
from spack.build_environment import get_std_cmake_args, setup_package
from spack.spec import Spec
from spack.util.executable import which
-
DATA_PATH = os.path.join(spack.paths.test_path, 'data')
diff --git a/lib/spack/spack/test/cache_fetch.py b/lib/spack/spack/test/cache_fetch.py
index 94ef7ec58e..0929bfd12c 100644
--- a/lib/spack/spack/test/cache_fetch.py
+++ b/lib/spack/spack/test/cache_fetch.py
@@ -4,14 +4,14 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
from llnl.util.filesystem import mkdirp, touch
import spack.config
-
-from spack.stage import Stage
from spack.fetch_strategy import CacheURLFetchStrategy, NoCacheError
+from spack.stage import Stage
@pytest.mark.parametrize('use_curl', [True, False])
diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py
index 20ec946835..99e0dbe303 100644
--- a/lib/spack/spack/test/cc.py
+++ b/lib/spack/spack/test/cc.py
@@ -8,10 +8,11 @@ This test checks that the Spack cc compiler wrapper is parsing
arguments correctly.
"""
import os
+
import pytest
from spack.paths import build_env_path
-from spack.util.environment import system_dirs, set_env
+from spack.util.environment import set_env, system_dirs
from spack.util.executable import Executable
#
diff --git a/lib/spack/spack/test/ci.py b/lib/spack/spack/test/ci.py
index bdf1af6849..4c7374df70 100644
--- a/lib/spack/spack/test/ci.py
+++ b/lib/spack/spack/test/ci.py
@@ -3,26 +3,27 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import collections
+import itertools as it
import json
import os
+
import pytest
import llnl.util.filesystem as fs
import spack.ci as ci
+import spack.ci_needs_workaround as cinw
+import spack.ci_optimization as ci_opt
+import spack.config as cfg
import spack.environment as ev
import spack.error
import spack.main as spack_main
-import spack.config as cfg
import spack.paths as spack_paths
import spack.spec as spec
import spack.util.gpg
-
-import spack.ci_optimization as ci_opt
-import spack.ci_needs_workaround as cinw
import spack.util.spack_yaml as syaml
-import itertools as it
-import collections
+
try:
# dynamically import to keep vermin from complaining
collections_abc = __import__('collections.abc')
diff --git a/lib/spack/spack/test/cmd/analyze.py b/lib/spack/spack/test/cmd/analyze.py
index 6d164063ab..03a0df100b 100644
--- a/lib/spack/spack/test/cmd/analyze.py
+++ b/lib/spack/spack/test/cmd/analyze.py
@@ -4,15 +4,15 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
+import spack.cmd.install
import spack.config
import spack.package
-import spack.cmd.install
-
-from spack.spec import Spec
import spack.util.spack_json as sjson
from spack.main import SpackCommand
+from spack.spec import Spec
install = SpackCommand('install')
analyze = SpackCommand('analyze')
diff --git a/lib/spack/spack/test/cmd/arch.py b/lib/spack/spack/test/cmd/arch.py
index cf4969ce28..0b058a0112 100644
--- a/lib/spack/spack/test/cmd/arch.py
+++ b/lib/spack/spack/test/cmd/arch.py
@@ -5,7 +5,6 @@
from spack.main import SpackCommand
-
arch = SpackCommand('arch')
diff --git a/lib/spack/spack/test/cmd/audit.py b/lib/spack/spack/test/cmd/audit.py
index 815a0cdf1b..84bbdbde5a 100644
--- a/lib/spack/spack/test/cmd/audit.py
+++ b/lib/spack/spack/test/cmd/audit.py
@@ -6,7 +6,6 @@ import pytest
from spack.main import SpackCommand
-
audit = SpackCommand('audit')
diff --git a/lib/spack/spack/test/cmd/blame.py b/lib/spack/spack/test/cmd/blame.py
index 40d3e92ea1..d90eea3ef7 100644
--- a/lib/spack/spack/test/cmd/blame.py
+++ b/lib/spack/spack/test/cmd/blame.py
@@ -6,10 +6,10 @@
import pytest
from llnl.util.filesystem import working_dir
-import spack.util.spack_json as sjson
-import spack.paths
import spack.cmd
+import spack.paths
+import spack.util.spack_json as sjson
from spack.main import SpackCommand
from spack.util.executable import which
diff --git a/lib/spack/spack/test/cmd/build_env.py b/lib/spack/spack/test/cmd/build_env.py
index d73b5bb972..d3d941f0b7 100644
--- a/lib/spack/spack/test/cmd/build_env.py
+++ b/lib/spack/spack/test/cmd/build_env.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from six.moves import cPickle
import pytest
+from six.moves import cPickle
from spack.main import SpackCommand
diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py
index addb286a41..d67f709a6b 100644
--- a/lib/spack/spack/test/cmd/buildcache.py
+++ b/lib/spack/spack/test/cmd/buildcache.py
@@ -4,14 +4,14 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import errno
-import platform
import os
+import platform
import pytest
-import spack.main
import spack.binary_distribution
import spack.environment as ev
+import spack.main
import spack.spec
from spack.spec import Spec
diff --git a/lib/spack/spack/test/cmd/cd.py b/lib/spack/spack/test/cmd/cd.py
index c8766503b4..95d2388284 100644
--- a/lib/spack/spack/test/cmd/cd.py
+++ b/lib/spack/spack/test/cmd/cd.py
@@ -5,7 +5,6 @@
from spack.main import SpackCommand
-
cd = SpackCommand('cd')
diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py
index 926afe2d9e..ea7d063b74 100644
--- a/lib/spack/spack/test/cmd/ci.py
+++ b/lib/spack/spack/test/cmd/ci.py
@@ -29,7 +29,6 @@ from spack.schema.gitlab_ci import schema as gitlab_ci_schema
from spack.spec import CompilerSpec, Spec
from spack.util.mock_package import MockPackageMultiRepo
-
ci_cmd = spack.main.SpackCommand('ci')
env_cmd = spack.main.SpackCommand('env')
mirror_cmd = spack.main.SpackCommand('mirror')
diff --git a/lib/spack/spack/test/cmd/clean.py b/lib/spack/spack/test/cmd/clean.py
index daf561eea4..ecc6c23b0a 100644
--- a/lib/spack/spack/test/cmd/clean.py
+++ b/lib/spack/spack/test/cmd/clean.py
@@ -4,10 +4,11 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
-import spack.stage
+
import spack.caches
import spack.main
import spack.package
+import spack.stage
clean = spack.main.SpackCommand('clean')
diff --git a/lib/spack/spack/test/cmd/commands.py b/lib/spack/spack/test/cmd/commands.py
index 2427511538..24aac549b1 100644
--- a/lib/spack/spack/test/cmd/commands.py
+++ b/lib/spack/spack/test/cmd/commands.py
@@ -11,10 +11,9 @@ import subprocess
import pytest
import spack.cmd
-from spack.cmd.commands import _positional_to_subroutine
import spack.main
import spack.paths
-
+from spack.cmd.commands import _positional_to_subroutine
commands = spack.main.SpackCommand('commands')
diff --git a/lib/spack/spack/test/cmd/compiler.py b/lib/spack/spack/test/cmd/compiler.py
index 109695edd8..2d554c2474 100644
--- a/lib/spack/spack/test/cmd/compiler.py
+++ b/lib/spack/spack/test/cmd/compiler.py
@@ -9,6 +9,7 @@ import sys
import pytest
import llnl.util.filesystem
+
import spack.main
import spack.version
diff --git a/lib/spack/spack/test/cmd/concretize.py b/lib/spack/spack/test/cmd/concretize.py
index ec8dbdf910..e701b31319 100644
--- a/lib/spack/spack/test/cmd/concretize.py
+++ b/lib/spack/spack/test/cmd/concretize.py
@@ -5,10 +5,10 @@
import pytest
+
import spack.environment as ev
from spack.main import SpackCommand
-
# everything here uses the mock_env_path
pytestmark = pytest.mark.usefixtures(
'mutable_mock_env_path', 'config', 'mutable_mock_repo')
diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py
index 32996310a6..acadbc761d 100644
--- a/lib/spack/spack/test/cmd/config.py
+++ b/lib/spack/spack/test/cmd/config.py
@@ -4,16 +4,18 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import functools
import os
+
import pytest
import llnl.util.filesystem as fs
+
import spack.config
+import spack.database
import spack.environment as ev
import spack.main
-import spack.util.spack_yaml as syaml
import spack.spec
-import spack.database
import spack.store
+import spack.util.spack_yaml as syaml
config = spack.main.SpackCommand('config')
env = spack.main.SpackCommand('env')
diff --git a/lib/spack/spack/test/cmd/create.py b/lib/spack/spack/test/cmd/create.py
index 39b076df08..896d8e1fe1 100644
--- a/lib/spack/spack/test/cmd/create.py
+++ b/lib/spack/spack/test/cmd/create.py
@@ -5,13 +5,13 @@
import argparse
import os
+
import pytest
import spack.cmd.create
import spack.util.editor
-from spack.url import UndetectableNameError
from spack.main import SpackCommand
-
+from spack.url import UndetectableNameError
create = SpackCommand('create')
diff --git a/lib/spack/spack/test/cmd/debug.py b/lib/spack/spack/test/cmd/debug.py
index 72190431de..6b54e531f0 100644
--- a/lib/spack/spack/test/cmd/debug.py
+++ b/lib/spack/spack/test/cmd/debug.py
@@ -3,13 +3,12 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+import os.path
import platform
import pytest
-import os
-import os.path
-
import spack.architecture as architecture
import spack.config
from spack.main import SpackCommand, get_version
diff --git a/lib/spack/spack/test/cmd/dependencies.py b/lib/spack/spack/test/cmd/dependencies.py
index 4c0de355ef..7ca1eae2e5 100644
--- a/lib/spack/spack/test/cmd/dependencies.py
+++ b/lib/spack/spack/test/cmd/dependencies.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
+
import pytest
from llnl.util.tty.color import color_when
diff --git a/lib/spack/spack/test/cmd/deprecate.py b/lib/spack/spack/test/cmd/deprecate.py
index 370d267753..204119155b 100644
--- a/lib/spack/spack/test/cmd/deprecate.py
+++ b/lib/spack/spack/test/cmd/deprecate.py
@@ -3,9 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
-from spack.main import SpackCommand
+
import spack.store
from spack.database import InstallStatuses
+from spack.main import SpackCommand
install = SpackCommand('install')
uninstall = SpackCommand('uninstall')
diff --git a/lib/spack/spack/test/cmd/dev_build.py b/lib/spack/spack/test/cmd/dev_build.py
index 11f4cbff82..f8be2364d9 100644
--- a/lib/spack/spack/test/cmd/dev_build.py
+++ b/lib/spack/spack/test/cmd/dev_build.py
@@ -4,10 +4,13 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
-import spack.spec
+
import llnl.util.filesystem as fs
+
import spack.environment as ev
+import spack.spec
from spack.main import SpackCommand
dev_build = SpackCommand('dev-build')
diff --git a/lib/spack/spack/test/cmd/develop.py b/lib/spack/spack/test/cmd/develop.py
index b6d8b11105..a1435eb706 100644
--- a/lib/spack/spack/test/cmd/develop.py
+++ b/lib/spack/spack/test/cmd/develop.py
@@ -2,13 +2,15 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import os
import shutil
+
+import pytest
+
import llnl.util.filesystem as fs
-import spack.spec
import spack.environment as ev
+import spack.spec
from spack.main import SpackCommand
develop = SpackCommand('develop')
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index 6c2ce34438..58094e1abb 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -4,27 +4,24 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
import os
-from six import StringIO
import pytest
+from six import StringIO
import llnl.util.filesystem as fs
import llnl.util.link_tree
+import spack.environment as ev
import spack.hash_types as ht
import spack.modules
-import spack.environment as ev
-
+import spack.util.spack_json as sjson
from spack.cmd.env import _env_create
-from spack.spec import Spec
from spack.main import SpackCommand, SpackCommandError
+from spack.spec import Spec
from spack.stage import stage_prefix
-
from spack.util.mock_package import MockPackageMultiRepo
-import spack.util.spack_json as sjson
from spack.util.path import substitute_path_variables
-
# everything here uses the mock_env_path
pytestmark = [
pytest.mark.usefixtures('mutable_mock_env_path', 'config', 'mutable_mock_repo'),
diff --git a/lib/spack/spack/test/cmd/extensions.py b/lib/spack/spack/test/cmd/extensions.py
index d2093fa887..90f065550d 100644
--- a/lib/spack/spack/test/cmd/extensions.py
+++ b/lib/spack/spack/test/cmd/extensions.py
@@ -8,7 +8,6 @@ import pytest
from spack.main import SpackCommand, SpackCommandError
from spack.spec import Spec
-
extensions = SpackCommand('extensions')
diff --git a/lib/spack/spack/test/cmd/external.py b/lib/spack/spack/test/cmd/external.py
index 3249a92894..69f107b33f 100644
--- a/lib/spack/spack/test/cmd/external.py
+++ b/lib/spack/spack/test/cmd/external.py
@@ -2,15 +2,15 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
-
import os
import os.path
+import pytest
+
import spack
-from spack.spec import Spec
from spack.cmd.external import ExternalPackageEntry
from spack.main import SpackCommand
+from spack.spec import Spec
def test_find_external_single_package(mock_executable):
diff --git a/lib/spack/spack/test/cmd/fetch.py b/lib/spack/spack/test/cmd/fetch.py
index 8a2b51c57b..212f0f58e7 100644
--- a/lib/spack/spack/test/cmd/fetch.py
+++ b/lib/spack/spack/test/cmd/fetch.py
@@ -6,10 +6,8 @@
import pytest
import spack.environment as ev
-
from spack.main import SpackCommand, SpackCommandError
-
# everything here uses the mock_env_path
pytestmark = pytest.mark.usefixtures(
"mutable_mock_env_path", "config", "mutable_mock_repo"
diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py
index 762578a028..21cd0359dc 100644
--- a/lib/spack/spack/test/cmd/find.py
+++ b/lib/spack/spack/test/cmd/find.py
@@ -8,14 +8,14 @@ import json
import os
import pytest
+
import spack.cmd as cmd
import spack.cmd.find
+import spack.environment as ev
import spack.user_environment as uenv
from spack.main import SpackCommand
from spack.spec import Spec
from spack.util.pattern import Bunch
-import spack.environment as ev
-
find = SpackCommand('find')
env = SpackCommand('env')
diff --git a/lib/spack/spack/test/cmd/gc.py b/lib/spack/spack/test/cmd/gc.py
index 70df8af687..e00c35ea7d 100644
--- a/lib/spack/spack/test/cmd/gc.py
+++ b/lib/spack/spack/test/cmd/gc.py
@@ -6,8 +6,8 @@
import pytest
import spack.environment as ev
-import spack.spec
import spack.main
+import spack.spec
gc = spack.main.SpackCommand('gc')
diff --git a/lib/spack/spack/test/cmd/gpg.py b/lib/spack/spack/test/cmd/gpg.py
index 3834876f58..6c9728d872 100644
--- a/lib/spack/spack/test/cmd/gpg.py
+++ b/lib/spack/spack/test/cmd/gpg.py
@@ -11,12 +11,10 @@ import llnl.util.filesystem as fs
import spack.util.executable
import spack.util.gpg
-
-from spack.paths import mock_gpg_data_path, mock_gpg_keys_path
from spack.main import SpackCommand
+from spack.paths import mock_gpg_data_path, mock_gpg_keys_path
from spack.util.executable import ProcessError
-
#: spack command used by tests below
gpg = SpackCommand('gpg')
diff --git a/lib/spack/spack/test/cmd/graph.py b/lib/spack/spack/test/cmd/graph.py
index 8d6da1049f..ee0081d4b0 100644
--- a/lib/spack/spack/test/cmd/graph.py
+++ b/lib/spack/spack/test/cmd/graph.py
@@ -3,10 +3,9 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from spack.main import SpackCommand, SpackCommandError
-
import pytest
+from spack.main import SpackCommand, SpackCommandError
graph = SpackCommand('graph')
diff --git a/lib/spack/spack/test/cmd/info.py b/lib/spack/spack/test/cmd/info.py
index b62a842b8b..01b9639f82 100644
--- a/lib/spack/spack/test/cmd/info.py
+++ b/lib/spack/spack/test/cmd/info.py
@@ -6,8 +6,8 @@
import argparse
import pytest
-import spack.cmd.info
+import spack.cmd.info
from spack.main import SpackCommand
info = SpackCommand('info')
diff --git a/lib/spack/spack/test/cmd/init_py_functions.py b/lib/spack/spack/test/cmd/init_py_functions.py
index 56b0ef7171..803cc4f13a 100644
--- a/lib/spack/spack/test/cmd/init_py_functions.py
+++ b/lib/spack/spack/test/cmd/init_py_functions.py
@@ -3,8 +3,15 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
-from spack.cmd import require_python_name, python_name, PythonNameError, \
- require_cmd_name, cmd_name, CommandNameError
+
+from spack.cmd import (
+ CommandNameError,
+ PythonNameError,
+ cmd_name,
+ python_name,
+ require_cmd_name,
+ require_python_name,
+)
def test_require_python_name():
diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py
index 328323b1af..022db42ba2 100644
--- a/lib/spack/spack/test/cmd/install.py
+++ b/lib/spack/spack/test/cmd/install.py
@@ -4,28 +4,27 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import argparse
-import os
import filecmp
+import os
import re
-from six.moves import builtins
-import time
import shutil
+import time
import pytest
+from six.moves import builtins
+from six.moves.urllib.error import HTTPError, URLError
import llnl.util.filesystem as fs
-import spack.config
+import spack.cmd.install
import spack.compilers as compilers
+import spack.config
+import spack.environment as ev
import spack.hash_types as ht
import spack.package
-import spack.cmd.install
from spack.error import SpackError
-from spack.spec import Spec, CompilerSpec
from spack.main import SpackCommand
-import spack.environment as ev
-
-from six.moves.urllib.error import HTTPError, URLError
+from spack.spec import CompilerSpec, Spec
install = SpackCommand('install')
env = SpackCommand('env')
diff --git a/lib/spack/spack/test/cmd/is_git_repo.py b/lib/spack/spack/test/cmd/is_git_repo.py
index fcfd1e010d..09c0ca0130 100644
--- a/lib/spack/spack/test/cmd/is_git_repo.py
+++ b/lib/spack/spack/test/cmd/is_git_repo.py
@@ -5,15 +5,14 @@
from __future__ import print_function
-import spack
import pytest
from llnl.util.filesystem import mkdirp
+import spack
from spack.util.executable import which
from spack.version import ver
-
git = which("git")
git_required_version = '2.17.0'
diff --git a/lib/spack/spack/test/cmd/license.py b/lib/spack/spack/test/cmd/license.py
index 6063a8d9a8..77207bbe6c 100644
--- a/lib/spack/spack/test/cmd/license.py
+++ b/lib/spack/spack/test/cmd/license.py
@@ -6,7 +6,7 @@
import os.path
import re
-from llnl.util.filesystem import touch, mkdirp
+from llnl.util.filesystem import mkdirp, touch
import spack.cmd.license
import spack.paths
diff --git a/lib/spack/spack/test/cmd/load.py b/lib/spack/spack/test/cmd/load.py
index 3f164b38b1..ef014418c7 100644
--- a/lib/spack/spack/test/cmd/load.py
+++ b/lib/spack/spack/test/cmd/load.py
@@ -3,10 +3,12 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
-from spack.main import SpackCommand, SpackCommandError
+
import spack.spec
import spack.user_environment as uenv
+from spack.main import SpackCommand, SpackCommandError
load = SpackCommand('load')
unload = SpackCommand('unload')
diff --git a/lib/spack/spack/test/cmd/location.py b/lib/spack/spack/test/cmd/location.py
index 98a13ce9da..db7c9d526a 100644
--- a/lib/spack/spack/test/cmd/location.py
+++ b/lib/spack/spack/test/cmd/location.py
@@ -5,14 +5,15 @@
import os
import shutil
+
import pytest
from llnl.util.filesystem import mkdirp
+
import spack.environment as ev
-from spack.main import SpackCommand, SpackCommandError
import spack.paths
import spack.stage
-
+from spack.main import SpackCommand, SpackCommandError
# Everything here uses (or can use) the mock config and database.
pytestmark = pytest.mark.usefixtures('config', 'database')
diff --git a/lib/spack/spack/test/cmd/maintainers.py b/lib/spack/spack/test/cmd/maintainers.py
index f6520b4a1b..0e4c8c6469 100644
--- a/lib/spack/spack/test/cmd/maintainers.py
+++ b/lib/spack/spack/test/cmd/maintainers.py
@@ -5,9 +5,10 @@
from __future__ import print_function
-import pytest
import re
+import pytest
+
import spack.main
import spack.repo
diff --git a/lib/spack/spack/test/cmd/mark.py b/lib/spack/spack/test/cmd/mark.py
index f51937071b..ff8283aa9f 100644
--- a/lib/spack/spack/test/cmd/mark.py
+++ b/lib/spack/spack/test/cmd/mark.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
+
import spack.store
from spack.main import SpackCommand, SpackCommandError
diff --git a/lib/spack/spack/test/cmd/mirror.py b/lib/spack/spack/test/cmd/mirror.py
index b72487e5ab..8716d59e05 100644
--- a/lib/spack/spack/test/cmd/mirror.py
+++ b/lib/spack/spack/test/cmd/mirror.py
@@ -3,12 +3,13 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import os
-from spack.main import SpackCommand, SpackCommandError
-import spack.environment as ev
+import pytest
+
import spack.config
+import spack.environment as ev
+from spack.main import SpackCommand, SpackCommandError
mirror = SpackCommand('mirror')
env = SpackCommand('env')
diff --git a/lib/spack/spack/test/cmd/pkg.py b/lib/spack/spack/test/cmd/pkg.py
index f9311b14bc..4036a33f95 100644
--- a/lib/spack/spack/test/cmd/pkg.py
+++ b/lib/spack/spack/test/cmd/pkg.py
@@ -5,14 +5,15 @@
from __future__ import print_function
-import pytest
import re
import shutil
+import pytest
+
from llnl.util.filesystem import mkdirp, working_dir
-import spack.main
import spack.cmd.pkg
+import spack.main
from spack.util.executable import which
pytestmark = pytest.mark.skipif(not which('git'),
diff --git a/lib/spack/spack/test/cmd/reindex.py b/lib/spack/spack/test/cmd/reindex.py
index 77c672251e..5f445081cc 100644
--- a/lib/spack/spack/test/cmd/reindex.py
+++ b/lib/spack/spack/test/cmd/reindex.py
@@ -3,8 +3,9 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
-from spack.main import SpackCommand
+
import spack.store
+from spack.main import SpackCommand
install = SpackCommand('install')
deprecate = SpackCommand('deprecate')
diff --git a/lib/spack/spack/test/cmd/repo.py b/lib/spack/spack/test/cmd/repo.py
index 541ffeddf0..bd2981620b 100644
--- a/lib/spack/spack/test/cmd/repo.py
+++ b/lib/spack/spack/test/cmd/repo.py
@@ -5,6 +5,7 @@
import os.path
import pytest
+
import spack.main
repo = spack.main.SpackCommand('repo')
diff --git a/lib/spack/spack/test/cmd/resource.py b/lib/spack/spack/test/cmd/resource.py
index ba1bf48daf..6623819d5e 100644
--- a/lib/spack/spack/test/cmd/resource.py
+++ b/lib/spack/spack/test/cmd/resource.py
@@ -5,7 +5,6 @@
from spack.main import SpackCommand
-
resource = SpackCommand('resource')
#: these are hashes used in mock packages
diff --git a/lib/spack/spack/test/cmd/spec.py b/lib/spack/spack/test/cmd/spec.py
index 7d5cf12e75..f3b0f577b1 100644
--- a/lib/spack/spack/test/cmd/spec.py
+++ b/lib/spack/spack/test/cmd/spec.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
+
import pytest
import spack.spec
diff --git a/lib/spack/spack/test/cmd/stage.py b/lib/spack/spack/test/cmd/stage.py
index 28ffc71451..bf590b0ea6 100644
--- a/lib/spack/spack/test/cmd/stage.py
+++ b/lib/spack/spack/test/cmd/stage.py
@@ -4,13 +4,14 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
-from spack.main import SpackCommand
+
import spack.environment as ev
import spack.repo
+from spack.main import SpackCommand
from spack.version import Version
-
stage = SpackCommand('stage')
env = SpackCommand('env')
diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py
index c0471fdfca..33dd81816b 100644
--- a/lib/spack/spack/test/cmd/test.py
+++ b/lib/spack/spack/test/cmd/test.py
@@ -8,10 +8,9 @@ import os
import pytest
+import spack.cmd.install
import spack.config
import spack.package
-import spack.cmd.install
-
from spack.cmd.test import has_test_method
from spack.main import SpackCommand
diff --git a/lib/spack/spack/test/cmd/undevelop.py b/lib/spack/spack/test/cmd/undevelop.py
index 0c8f2df978..583c24887a 100644
--- a/lib/spack/spack/test/cmd/undevelop.py
+++ b/lib/spack/spack/test/cmd/undevelop.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import spack.spec
import spack.environment as ev
+import spack.spec
from spack.main import SpackCommand
undevelop = SpackCommand('undevelop')
diff --git a/lib/spack/spack/test/cmd/uninstall.py b/lib/spack/spack/test/cmd/uninstall.py
index 916b8adfab..a3d26a5860 100644
--- a/lib/spack/spack/test/cmd/uninstall.py
+++ b/lib/spack/spack/test/cmd/uninstall.py
@@ -4,7 +4,9 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
+
import llnl.util.tty as tty
+
import spack.store
from spack.main import SpackCommand, SpackCommandError
diff --git a/lib/spack/spack/test/cmd/url.py b/lib/spack/spack/test/cmd/url.py
index c130840984..b5b2b9feba 100644
--- a/lib/spack/spack/test/cmd/url.py
+++ b/lib/spack/spack/test/cmd/url.py
@@ -8,11 +8,9 @@ import sys
import pytest
import spack.repo
-from spack.url import UndetectableVersionError
+from spack.cmd.url import name_parsed_correctly, url_summary, version_parsed_correctly
from spack.main import SpackCommand
-from spack.cmd.url import name_parsed_correctly, version_parsed_correctly
-from spack.cmd.url import url_summary
-
+from spack.url import UndetectableVersionError
url = SpackCommand('url')
diff --git a/lib/spack/spack/test/cmd/verify.py b/lib/spack/spack/test/cmd/verify.py
index de7544d9f1..a72bfe85df 100644
--- a/lib/spack/spack/test/cmd/verify.py
+++ b/lib/spack/spack/test/cmd/verify.py
@@ -8,10 +8,10 @@ import os
import llnl.util.filesystem as fs
-import spack.util.spack_json as sjson
-import spack.verify
import spack.spec
import spack.store
+import spack.util.spack_json as sjson
+import spack.verify
from spack.main import SpackCommand
verify = SpackCommand('verify')
diff --git a/lib/spack/spack/test/cmd/view.py b/lib/spack/spack/test/cmd/view.py
index b5a503d278..594a182901 100644
--- a/lib/spack/spack/test/cmd/view.py
+++ b/lib/spack/spack/test/cmd/view.py
@@ -3,11 +3,12 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from spack.main import SpackCommand
import os.path
+
import pytest
import spack.util.spack_yaml as s_yaml
+from spack.main import SpackCommand
activate = SpackCommand('activate')
extensions = SpackCommand('extensions')
diff --git a/lib/spack/spack/test/cmd_extensions.py b/lib/spack/spack/test/cmd_extensions.py
index f611bd5c8f..18a231817e 100644
--- a/lib/spack/spack/test/cmd_extensions.py
+++ b/lib/spack/spack/test/cmd_extensions.py
@@ -3,12 +3,12 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
-
import contextlib
import os
import sys
+import pytest
+
import spack.cmd
import spack.config
import spack.extensions
diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py
index d740862905..9ad574ada9 100644
--- a/lib/spack/spack/test/compilers/basics.py
+++ b/lib/spack/spack/test/compilers/basics.py
@@ -3,23 +3,20 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Test basic behavior of compilers in Spack"""
-import pytest
-
-import sys
import os
import shutil
-
+import sys
from copy import copy
+
+import pytest
from six import iteritems
import llnl.util.filesystem as fs
-import spack.spec
import spack.compiler
import spack.compilers as compilers
import spack.spec
import spack.util.environment
-
from spack.compiler import Compiler
from spack.util.executable import ProcessError
diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py
index bcc9550aae..58d03fbfe4 100644
--- a/lib/spack/spack/test/compilers/detection.py
+++ b/lib/spack/spack/test/compilers/detection.py
@@ -8,6 +8,7 @@ import os
import pytest
import llnl.util.filesystem as fs
+
import spack.compilers.aocc
import spack.compilers.arm
import spack.compilers.cce
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index b9354ffe10..757fdc2706 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -4,24 +4,23 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
-import pytest
import jinja2
+import pytest
import archspec.cpu
import llnl.util.lang
import spack.architecture
+import spack.compilers
import spack.concretize
import spack.error
+import spack.platforms.test
import spack.repo
-
from spack.concretize import find_spec
from spack.spec import Spec
-from spack.version import ver
from spack.util.mock_package import MockPackageMultiRepo
-import spack.compilers
-import spack.platforms.test
+from spack.version import ver
def check_spec(abstract, concrete):
diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py
index 7abbaa6e92..b5b631d6af 100644
--- a/lib/spack/spack/test/concretize_preferences.py
+++ b/lib/spack/spack/test/concretize_preferences.py
@@ -3,14 +3,15 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import stat
+import pytest
+
import spack.config
import spack.package_prefs
import spack.repo
import spack.util.spack_yaml as syaml
-from spack.config import ConfigScope, ConfigError
+from spack.config import ConfigError, ConfigScope
from spack.spec import Spec
from spack.version import Version
diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py
index 40bcab0e31..94966c9fac 100644
--- a/lib/spack/spack/test/config.py
+++ b/lib/spack/spack/test/config.py
@@ -3,29 +3,28 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
import collections
import getpass
+import os
import tempfile
-from six import StringIO
-
-from llnl.util.filesystem import touch, mkdirp
import pytest
+from six import StringIO
+
+from llnl.util.filesystem import mkdirp, touch
-import spack.paths
import spack.config
-import spack.main
import spack.environment
+import spack.main
+import spack.paths
import spack.schema.compilers
import spack.schema.config
import spack.schema.env
-import spack.schema.packages
import spack.schema.mirrors
+import spack.schema.packages
import spack.schema.repos
-import spack.util.spack_yaml as syaml
import spack.util.path as spack_path
-
+import spack.util.spack_yaml as syaml
# sample config data
config_low = {
diff --git a/lib/spack/spack/test/container/cli.py b/lib/spack/spack/test/container/cli.py
index 26ae9f0c68..1dd0840d7f 100644
--- a/lib/spack/spack/test/container/cli.py
+++ b/lib/spack/spack/test/container/cli.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import llnl.util.filesystem as fs
-import spack.main
+import spack.main
containerize = spack.main.SpackCommand('containerize')
diff --git a/lib/spack/spack/test/cvs_fetch.py b/lib/spack/spack/test/cvs_fetch.py
index 8bf4c20acb..07688bb6f4 100644
--- a/lib/spack/spack/test/cvs_fetch.py
+++ b/lib/spack/spack/test/cvs_fetch.py
@@ -7,16 +7,15 @@ import os
import pytest
-from llnl.util.filesystem import touch, working_dir, mkdirp
+from llnl.util.filesystem import mkdirp, touch, working_dir
-import spack.repo
import spack.config
+import spack.repo
+from spack.fetch_strategy import CvsFetchStrategy
from spack.spec import Spec
from spack.stage import Stage
-from spack.version import ver
-from spack.fetch_strategy import CvsFetchStrategy
from spack.util.executable import which
-
+from spack.version import ver
pytestmark = pytest.mark.skipif(
not which('cvs'),
diff --git a/lib/spack/spack/test/database.py b/lib/spack/spack/test/database.py
index c8c12eac39..37d19d6794 100644
--- a/lib/spack/spack/test/database.py
+++ b/lib/spack/spack/test/database.py
@@ -9,9 +9,11 @@ both in memory and in its file
"""
import datetime
import functools
+import json
import os
+
import pytest
-import json
+
try:
import uuid
_use_uuid = True
@@ -24,15 +26,14 @@ from jsonschema import validate
import llnl.util.lock as lk
from llnl.util.tty.colify import colify
-import spack.repo
-import spack.store
import spack.database
import spack.package
+import spack.repo
import spack.spec
-from spack.util.mock_package import MockPackageMultiRepo
-from spack.util.executable import Executable
+import spack.store
from spack.schema.database_index import schema
-
+from spack.util.executable import Executable
+from spack.util.mock_package import MockPackageMultiRepo
pytestmark = pytest.mark.db
diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py
index 73446714ba..90b83b6430 100644
--- a/lib/spack/spack/test/directory_layout.py
+++ b/lib/spack/spack/test/directory_layout.py
@@ -8,12 +8,15 @@ This test verifies that the Spack directory layout works properly.
"""
import os
import os.path
+
import pytest
import spack.paths
import spack.repo
-from spack.directory_layout import YamlDirectoryLayout
-from spack.directory_layout import InvalidDirectoryLayoutParametersError
+from spack.directory_layout import (
+ InvalidDirectoryLayoutParametersError,
+ YamlDirectoryLayout,
+)
from spack.spec import Spec
# number of packages to test (to reduce test time)
diff --git a/lib/spack/spack/test/environment_modifications.py b/lib/spack/spack/test/environment_modifications.py
index 014bf340bf..aa27132fbf 100644
--- a/lib/spack/spack/test/environment_modifications.py
+++ b/lib/spack/spack/test/environment_modifications.py
@@ -6,13 +6,19 @@
import os
import pytest
+
import spack.util.environment as environment
from spack.paths import spack_root
-from spack.util.environment import EnvironmentModifications
-from spack.util.environment import RemovePath, PrependPath, AppendPath
-from spack.util.environment import SetEnv, UnsetEnv
-from spack.util.environment import filter_system_paths, is_system_path
-
+from spack.util.environment import (
+ AppendPath,
+ EnvironmentModifications,
+ PrependPath,
+ RemovePath,
+ SetEnv,
+ UnsetEnv,
+ filter_system_paths,
+ is_system_path,
+)
datadir = os.path.join(spack_root, 'lib', 'spack', 'spack', 'test', 'data')
diff --git a/lib/spack/spack/test/flag_handlers.py b/lib/spack/spack/test/flag_handlers.py
index 8fac5a898c..4ec849a266 100644
--- a/lib/spack/spack/test/flag_handlers.py
+++ b/lib/spack/spack/test/flag_handlers.py
@@ -3,14 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import os
-import spack.spec
-import spack.repo
-import spack.build_environment
+import pytest
-from spack.pkgkit import inject_flags, env_flags, build_system_flags
+import spack.build_environment
+import spack.repo
+import spack.spec
+from spack.pkgkit import build_system_flags, env_flags, inject_flags
@pytest.fixture()
diff --git a/lib/spack/spack/test/git_fetch.py b/lib/spack/spack/test/git_fetch.py
index e06077df83..1ac7b473c7 100644
--- a/lib/spack/spack/test/git_fetch.py
+++ b/lib/spack/spack/test/git_fetch.py
@@ -9,15 +9,15 @@ import shutil
import pytest
-from llnl.util.filesystem import working_dir, touch, mkdirp
+from llnl.util.filesystem import mkdirp, touch, working_dir
-import spack.repo
import spack.config
+import spack.repo
+from spack.fetch_strategy import GitFetchStrategy
from spack.spec import Spec
from spack.stage import Stage
-from spack.version import ver
-from spack.fetch_strategy import GitFetchStrategy
from spack.util.executable import which
+from spack.version import ver
pytestmark = pytest.mark.skipif(
not which('git'), reason='requires git to be installed')
diff --git a/lib/spack/spack/test/graph.py b/lib/spack/spack/test/graph.py
index 76c9524728..997d4ffe58 100644
--- a/lib/spack/spack/test/graph.py
+++ b/lib/spack/spack/test/graph.py
@@ -6,8 +6,8 @@
from six import StringIO
import spack.repo
+from spack.graph import AsciiGraph, graph_dot, topological_sort
from spack.spec import Spec
-from spack.graph import AsciiGraph, topological_sort, graph_dot
def test_topo_sort(mock_packages):
diff --git a/lib/spack/spack/test/hg_fetch.py b/lib/spack/spack/test/hg_fetch.py
index d0f7629cf8..e3e5364904 100644
--- a/lib/spack/spack/test/hg_fetch.py
+++ b/lib/spack/spack/test/hg_fetch.py
@@ -7,16 +7,15 @@ import os
import pytest
-from llnl.util.filesystem import working_dir, touch, mkdirp
+from llnl.util.filesystem import mkdirp, touch, working_dir
-import spack.repo
import spack.config
+import spack.repo
+from spack.fetch_strategy import HgFetchStrategy
from spack.spec import Spec
from spack.stage import Stage
-from spack.version import ver
-from spack.fetch_strategy import HgFetchStrategy
from spack.util.executable import which
-
+from spack.version import ver
pytestmark = pytest.mark.skipif(
not which('hg'), reason='requires mercurial to be installed')
diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py
index 90bab99c20..f71c77a35b 100644
--- a/lib/spack/spack/test/install.py
+++ b/lib/spack/spack/test/install.py
@@ -9,14 +9,20 @@ import shutil
import pytest
import llnl.util.filesystem as fs
+
import spack.error
import spack.patch
import spack.repo
import spack.store
import spack.util.spack_json as sjson
-from spack.package import InstallError, PackageBase, PackageStillNeededError
-from spack.package import (_spack_build_envfile, _spack_build_logfile,
- _spack_configure_argsfile)
+from spack.package import (
+ InstallError,
+ PackageBase,
+ PackageStillNeededError,
+ _spack_build_envfile,
+ _spack_build_logfile,
+ _spack_configure_argsfile,
+)
from spack.spec import Spec
diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py
index c71bd83586..76dddc9a4f 100644
--- a/lib/spack/spack/test/installer.py
+++ b/lib/spack/spack/test/installer.py
@@ -4,12 +4,13 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import py
import pytest
import llnl.util.filesystem as fs
-import llnl.util.tty as tty
import llnl.util.lock as ulk
+import llnl.util.tty as tty
import spack.binary_distribution
import spack.compilers
diff --git a/lib/spack/spack/test/link_paths.py b/lib/spack/spack/test/link_paths.py
index 4485bf3ae8..c1ce12d73b 100644
--- a/lib/spack/spack/test/link_paths.py
+++ b/lib/spack/spack/test/link_paths.py
@@ -2,9 +2,10 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import os
+import pytest
+
import spack.paths
from spack.compiler import _parse_non_system_link_dirs
diff --git a/lib/spack/spack/test/llnl/util/argparsewriter.py b/lib/spack/spack/test/llnl/util/argparsewriter.py
index 708110558e..deba013363 100644
--- a/lib/spack/spack/test/llnl/util/argparsewriter.py
+++ b/lib/spack/spack/test/llnl/util/argparsewriter.py
@@ -15,7 +15,6 @@ import llnl.util.argparsewriter as aw
import spack.main
-
parser = spack.main.make_argument_parser()
spack.main.add_all_commands(parser)
diff --git a/lib/spack/spack/test/llnl/util/file_list.py b/lib/spack/spack/test/llnl/util/file_list.py
index 4efec18067..964098ce1a 100644
--- a/lib/spack/spack/test/llnl/util/file_list.py
+++ b/lib/spack/spack/test/llnl/util/file_list.py
@@ -3,14 +3,19 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
import fnmatch
+import os
-import six
import pytest
+import six
-from llnl.util.filesystem import LibraryList, HeaderList
-from llnl.util.filesystem import find_libraries, find_headers, find
+from llnl.util.filesystem import (
+ HeaderList,
+ LibraryList,
+ find,
+ find_headers,
+ find_libraries,
+)
import spack.paths
diff --git a/lib/spack/spack/test/llnl/util/filesystem.py b/lib/spack/spack/test/llnl/util/filesystem.py
index 5733be6b59..0db8e93ae8 100644
--- a/lib/spack/spack/test/llnl/util/filesystem.py
+++ b/lib/spack/spack/test/llnl/util/filesystem.py
@@ -12,6 +12,7 @@ import sys
import pytest
import llnl.util.filesystem as fs
+
import spack.paths
diff --git a/lib/spack/spack/test/llnl/util/lang.py b/lib/spack/spack/test/llnl/util/lang.py
index 99829f49d9..80e4ff92fa 100644
--- a/lib/spack/spack/test/llnl/util/lang.py
+++ b/lib/spack/spack/test/llnl/util/lang.py
@@ -3,14 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
-
import os.path
import sys
from datetime import datetime, timedelta
+import pytest
+
import llnl.util.lang
-from llnl.util.lang import pretty_date, match_predicate
+from llnl.util.lang import match_predicate, pretty_date
@pytest.fixture()
diff --git a/lib/spack/spack/test/llnl/util/link_tree.py b/lib/spack/spack/test/llnl/util/link_tree.py
index af7012692f..84fa306135 100644
--- a/lib/spack/spack/test/llnl/util/link_tree.py
+++ b/lib/spack/spack/test/llnl/util/link_tree.py
@@ -6,8 +6,10 @@
import os
import pytest
-from llnl.util.filesystem import working_dir, mkdirp, touchp
+
+from llnl.util.filesystem import mkdirp, touchp, working_dir
from llnl.util.link_tree import LinkTree
+
from spack.stage import Stage
diff --git a/lib/spack/spack/test/llnl/util/lock.py b/lib/spack/spack/test/llnl/util/lock.py
index 928bded6ca..3d91ce075d 100644
--- a/lib/spack/spack/test/llnl/util/lock.py
+++ b/lib/spack/spack/test/llnl/util/lock.py
@@ -45,13 +45,13 @@ actually on a shared filesystem.
import collections
import errno
import fcntl
+import getpass
+import glob
import os
-import socket
import shutil
+import socket
import tempfile
import traceback
-import glob
-import getpass
from contextlib import contextmanager
from multiprocessing import Process, Queue
@@ -61,7 +61,6 @@ import llnl.util.lock as lk
import llnl.util.multiproc as mp
from llnl.util.filesystem import touch
-
#
# This test can be run with MPI. MPI is "enabled" if we can import
# mpi4py and the number of total MPI processes is greater than 1.
diff --git a/lib/spack/spack/test/llnl/util/tty/log.py b/lib/spack/spack/test/llnl/util/tty/log.py
index 080a6e1339..279985001d 100644
--- a/lib/spack/spack/test/llnl/util/tty/log.py
+++ b/lib/spack/spack/test/llnl/util/tty/log.py
@@ -4,15 +4,15 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from __future__ import print_function
+
import contextlib
import multiprocessing
import os
import signal
import sys
import time
-
-from typing import Optional # novm
from types import ModuleType # novm
+from typing import Optional # novm
import pytest
diff --git a/lib/spack/spack/test/llnl/util/tty/tty.py b/lib/spack/spack/test/llnl/util/tty/tty.py
index bc68543ec3..6bfea98be1 100644
--- a/lib/spack/spack/test/llnl/util/tty/tty.py
+++ b/lib/spack/spack/test/llnl/util/tty/tty.py
@@ -6,6 +6,7 @@
import os
import pytest
+
import llnl.util.tty as tty
diff --git a/lib/spack/spack/test/mirror.py b/lib/spack/spack/test/mirror.py
index 2eef86e4f4..5abc3c3e14 100644
--- a/lib/spack/spack/test/mirror.py
+++ b/lib/spack/spack/test/mirror.py
@@ -5,17 +5,18 @@
import filecmp
import os
+
import pytest
-import spack.repo
+from llnl.util.filesystem import resolve_link_target_relative_to_the_link
+
import spack.mirror
+import spack.repo
import spack.util.executable
from spack.spec import Spec
from spack.stage import Stage
from spack.util.executable import which
-from llnl.util.filesystem import resolve_link_target_relative_to_the_link
-
pytestmark = pytest.mark.usefixtures('mutable_config', 'mutable_mock_repo')
# paths in repos that shouldn't be in the mirror tarballs.
diff --git a/lib/spack/spack/test/module_parsing.py b/lib/spack/spack/test/module_parsing.py
index a1d0142b92..bcaf292263 100644
--- a/lib/spack/spack/test/module_parsing.py
+++ b/lib/spack/spack/test/module_parsing.py
@@ -3,15 +3,16 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import os
-import spack
+import pytest
+
+import spack
from spack.util.module_cmd import (
+ get_path_args_from_module_line,
+ get_path_from_module_contents,
module,
path_from_modules,
- get_path_args_from_module_line,
- get_path_from_module_contents
)
test_module_lines = ['prepend-path LD_LIBRARY_PATH /path/to/lib',
diff --git a/lib/spack/spack/test/modules/common.py b/lib/spack/spack/test/modules/common.py
index 8270b01c71..61303cc7a6 100644
--- a/lib/spack/spack/test/modules/common.py
+++ b/lib/spack/spack/test/modules/common.py
@@ -3,18 +3,18 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import collections
import os
import stat
+
import pytest
-import collections
-import spack.spec
+import spack.error
import spack.modules.tcl
+import spack.spec
from spack.modules.common import UpstreamModuleIndex
from spack.spec import Spec
-import spack.error
-
def test_update_dictionary_extending_list():
target = {
diff --git a/lib/spack/spack/test/modules/conftest.py b/lib/spack/spack/test/modules/conftest.py
index ea61a3b955..2ac22fe3b4 100644
--- a/lib/spack/spack/test/modules/conftest.py
+++ b/lib/spack/spack/test/modules/conftest.py
@@ -5,9 +5,9 @@
import pytest
import spack.config
+import spack.modules.common
import spack.paths
import spack.spec
-import spack.modules.common
import spack.util.path
diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py
index 049bddcd9a..5f839085fa 100644
--- a/lib/spack/spack/test/modules/lmod.py
+++ b/lib/spack/spack/test/modules/lmod.py
@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
+
import pytest
import spack.environment as ev
diff --git a/lib/spack/spack/test/monitor.py b/lib/spack/spack/test/monitor.py
index 77c2754d44..b060c725ee 100644
--- a/lib/spack/spack/test/monitor.py
+++ b/lib/spack/spack/test/monitor.py
@@ -3,14 +3,17 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+import pytest
+
+import llnl.util.tty as tty
+
import spack.config
+import spack.monitor
import spack.spec
from spack.main import SpackCommand
from spack.monitor import SpackMonitorClient
-import llnl.util.tty as tty
-import spack.monitor
-import pytest
-import os
install = SpackCommand('install')
diff --git a/lib/spack/spack/test/multimethod.py b/lib/spack/spack/test/multimethod.py
index beb92bbb6d..6169584d96 100644
--- a/lib/spack/spack/test/multimethod.py
+++ b/lib/spack/spack/test/multimethod.py
@@ -9,7 +9,6 @@ import pytest
import spack.repo
from spack.multimethod import NoSuchMethodError
-
pytestmark = pytest.mark.usefixtures('mock_packages')
diff --git a/lib/spack/spack/test/optional_deps.py b/lib/spack/spack/test/optional_deps.py
index fe73a0ae8a..9073a8ce19 100644
--- a/lib/spack/spack/test/optional_deps.py
+++ b/lib/spack/spack/test/optional_deps.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
+
from spack.spec import Spec
diff --git a/lib/spack/spack/test/package_class.py b/lib/spack/spack/test/package_class.py
index 686c956186..22939105a4 100644
--- a/lib/spack/spack/test/package_class.py
+++ b/lib/spack/spack/test/package_class.py
@@ -11,9 +11,10 @@ static DSL metadata for packages.
"""
import os
-import pytest
import shutil
+import pytest
+
import llnl.util.filesystem as fs
import spack.package
diff --git a/lib/spack/spack/test/package_hash.py b/lib/spack/spack/test/package_hash.py
index bcb1f6b804..6e50fee5ce 100644
--- a/lib/spack/spack/test/package_hash.py
+++ b/lib/spack/spack/test/package_hash.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-from spack.util.package_hash import package_hash, package_content
from spack.spec import Spec
+from spack.util.package_hash import package_content, package_hash
def test_hash(tmpdir, mock_packages, config):
diff --git a/lib/spack/spack/test/package_sanity.py b/lib/spack/spack/test/package_sanity.py
index 308706a5a7..f65e008ef4 100644
--- a/lib/spack/spack/test/package_sanity.py
+++ b/lib/spack/spack/test/package_sanity.py
@@ -4,23 +4,23 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""This test does sanity checks on Spack's builtin package database."""
import os.path
+import pickle
import re
import pytest
+import llnl.util.tty as tty
+
+# A few functions from this module are used to
+# do sanity checks only on packagess modified by a PR
+import spack.cmd.style as style
import spack.fetch_strategy
import spack.package
import spack.paths
import spack.repo
+import spack.util.crypto as crypto
import spack.util.executable as executable
import spack.variant
-# A few functions from this module are used to
-# do sanity checks only on packagess modified by a PR
-import spack.cmd.style as style
-import spack.util.crypto as crypto
-import pickle
-
-import llnl.util.tty as tty
def check_repo():
diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py
index c821d5b5c7..16e209c42c 100644
--- a/lib/spack/spack/test/packages.py
+++ b/lib/spack/spack/test/packages.py
@@ -4,16 +4,17 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os.path
+
import pytest
-import spack.repo
+import spack.directives
import spack.fetch_strategy
+import spack.repo
from spack.paths import mock_packages_path
-from spack.util.naming import mod_to_class
from spack.spec import Spec
+from spack.util.naming import mod_to_class
from spack.util.package_hash import package_content
from spack.version import VersionChecksumError
-import spack.directives
def _generate_content_strip_name(spec):
@@ -109,7 +110,6 @@ class TestPackage(object):
def test_import_package_as(self):
import spack.pkg.builtin.mock.mpich as mp # noqa
-
import spack.pkg.builtin.mock # noqa
import spack.pkg.builtin.mock as m # noqa
from spack.pkg.builtin import mock # noqa
@@ -161,11 +161,9 @@ class TestPackage(object):
import spack.pkg # noqa
import spack.pkg as p # noqa
from spack import pkg # noqa
-
import spack.pkg.builtin # noqa
import spack.pkg.builtin as b # noqa
from spack.pkg import builtin # noqa
-
import spack.pkg.builtin.mock # noqa
import spack.pkg.builtin.mock as m # noqa
from spack.pkg.builtin import mock # noqa
diff --git a/lib/spack/spack/test/packaging.py b/lib/spack/spack/test/packaging.py
index bd02214512..cb3d146745 100644
--- a/lib/spack/spack/test/packaging.py
+++ b/lib/spack/spack/test/packaging.py
@@ -6,30 +6,36 @@
"""
This test checks the binary packaging infrastructure
"""
+import argparse
import os
-import stat
+import platform
+import re
import shutil
+import stat
+
import pytest
-import argparse
-import re
-import platform
from llnl.util.filesystem import mkdirp
-import spack.repo
-import spack.store
import spack.binary_distribution as bindist
import spack.cmd.buildcache as buildcache
+import spack.repo
+import spack.store
import spack.util.gpg
-from spack.spec import Spec
+from spack.fetch_strategy import FetchStrategyComposite, URLFetchStrategy
from spack.paths import mock_gpg_keys_path
-from spack.fetch_strategy import URLFetchStrategy, FetchStrategyComposite
-from spack.relocate import needs_binary_relocation, needs_text_relocation
-from spack.relocate import relocate_text, relocate_links
-from spack.relocate import macho_make_paths_relative
-from spack.relocate import macho_make_paths_normal
-from spack.relocate import _placeholder, macho_find_paths
-from spack.relocate import file_is_relocatable
+from spack.relocate import (
+ _placeholder,
+ file_is_relocatable,
+ macho_find_paths,
+ macho_make_paths_normal,
+ macho_make_paths_relative,
+ needs_binary_relocation,
+ needs_text_relocation,
+ relocate_links,
+ relocate_text,
+)
+from spack.spec import Spec
def fake_fetchify(url, pkg):
diff --git a/lib/spack/spack/test/patch.py b/lib/spack/spack/test/patch.py
index 57a5669c57..8383100440 100644
--- a/lib/spack/spack/test/patch.py
+++ b/lib/spack/spack/test/patch.py
@@ -3,20 +3,21 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
+import collections
import filecmp
+import os
+
import pytest
-import collections
-from llnl.util.filesystem import working_dir, mkdirp
+from llnl.util.filesystem import mkdirp, working_dir
import spack.patch
import spack.paths
import spack.repo
import spack.util.compression
-from spack.util.executable import Executable
-from spack.stage import Stage
from spack.spec import Spec
+from spack.stage import Stage
+from spack.util.executable import Executable
# various sha256 sums (using variables for legibility)
diff --git a/lib/spack/spack/test/pattern.py b/lib/spack/spack/test/pattern.py
index 94f4e6d5f0..a12f5e4e4a 100644
--- a/lib/spack/spack/test/pattern.py
+++ b/lib/spack/spack/test/pattern.py
@@ -5,6 +5,7 @@
import pytest
+
import spack.util.pattern as pattern
diff --git a/lib/spack/spack/test/permissions.py b/lib/spack/spack/test/permissions.py
index 320ff2fdba..e4c0eca8f8 100644
--- a/lib/spack/spack/test/permissions.py
+++ b/lib/spack/spack/test/permissions.py
@@ -4,14 +4,14 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
-import pytest
import stat
-from spack.util.file_permissions import (
- set_permissions, InvalidPermissionsError
-)
+import pytest
+
import llnl.util.filesystem as fs
+from spack.util.file_permissions import InvalidPermissionsError, set_permissions
+
def test_chmod_real_entries_ignores_suid_sgid(tmpdir):
path = str(tmpdir.join('file').ensure())
diff --git a/lib/spack/spack/test/relocate.py b/lib/spack/spack/test/relocate.py
index fb1ed4eb60..8f7e084e4d 100644
--- a/lib/spack/spack/test/relocate.py
+++ b/lib/spack/spack/test/relocate.py
@@ -8,8 +8,10 @@ import platform
import re
import shutil
-import llnl.util.filesystem
import pytest
+
+import llnl.util.filesystem
+
import spack.architecture
import spack.concretize
import spack.paths
diff --git a/lib/spack/spack/test/repo.py b/lib/spack/spack/test/repo.py
index df3015500d..f4c83f630a 100644
--- a/lib/spack/spack/test/repo.py
+++ b/lib/spack/spack/test/repo.py
@@ -4,10 +4,11 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
-import spack.repo
import spack.paths
+import spack.repo
@pytest.fixture()
diff --git a/lib/spack/spack/test/s3_fetch.py b/lib/spack/spack/test/s3_fetch.py
index 6f546ccc36..2fc9e3de84 100644
--- a/lib/spack/spack/test/s3_fetch.py
+++ b/lib/spack/spack/test/s3_fetch.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
import spack.config as spack_config
diff --git a/lib/spack/spack/test/sbang.py b/lib/spack/spack/test/sbang.py
index 422ec3cdc0..57ae2ba0f6 100644
--- a/lib/spack/spack/test/sbang.py
+++ b/lib/spack/spack/test/sbang.py
@@ -6,21 +6,21 @@
"""\
Test that Spack's shebang filtering works correctly.
"""
+import filecmp
import os
+import shutil
import stat
-import pytest
import tempfile
-import shutil
-import filecmp
+
+import pytest
import llnl.util.filesystem as fs
+import spack.hooks.sbang as sbang
import spack.paths
import spack.store
-import spack.hooks.sbang as sbang
from spack.util.executable import which
-
too_long = sbang.shebang_limit + 1
diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py
index ea16f655db..080f26000d 100644
--- a/lib/spack/spack/test/spec_dag.py
+++ b/lib/spack/spack/test/spec_dag.py
@@ -6,14 +6,14 @@
These tests check Spec DAG operations using dummy packages.
"""
import pytest
+
import spack.architecture
import spack.error
import spack.package
-
+import spack.util.hash as hashutil
+from spack.dependency import Dependency, all_deptypes, canonical_deptype
from spack.spec import Spec
-from spack.dependency import all_deptypes, Dependency, canonical_deptype
from spack.util.mock_package import MockPackageMultiRepo
-import spack.util.hash as hashutil
def check_links(spec_to_check):
diff --git a/lib/spack/spack/test/spec_list.py b/lib/spack/spack/test/spec_list.py
index 48796d0ad9..d6461b00d5 100644
--- a/lib/spack/spack/test/spec_list.py
+++ b/lib/spack/spack/test/spec_list.py
@@ -2,10 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import itertools
-from spack.spec_list import SpecList
+
+import pytest
+
from spack.spec import Spec
+from spack.spec_list import SpecList
class TestSpecList(object):
diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py
index 16a4cf77ce..c21be38491 100644
--- a/lib/spack/spack/test/spec_semantics.py
+++ b/lib/spack/spack/test/spec_semantics.py
@@ -4,18 +4,25 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
-import pytest
-from spack.error import SpecError, UnsatisfiableSpecError
-from spack.spec import UnconstrainableDependencySpecError
-from spack.spec import Spec, SpecFormatSigilError, SpecFormatStringError
-from spack.variant import InvalidVariantValueError, UnknownVariantError
-from spack.variant import MultipleValuesInExclusiveVariantError
-from spack.variant import substitute_abstract_variants
+import pytest
import spack.architecture
import spack.directives
import spack.error
+from spack.error import SpecError, UnsatisfiableSpecError
+from spack.spec import (
+ Spec,
+ SpecFormatSigilError,
+ SpecFormatStringError,
+ UnconstrainableDependencySpecError,
+)
+from spack.variant import (
+ InvalidVariantValueError,
+ MultipleValuesInExclusiveVariantError,
+ UnknownVariantError,
+ substitute_abstract_variants,
+)
def make_spec(spec_like, concrete):
diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py
index fd5108c809..58e8770628 100644
--- a/lib/spack/spack/test/spec_syntax.py
+++ b/lib/spack/spack/test/spec_syntax.py
@@ -4,26 +4,33 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import itertools
import os
-import pytest
import shlex
+import pytest
+
import llnl.util.filesystem as fs
import spack.hash_types as ht
import spack.repo
-import spack.store
import spack.spec as sp
+import spack.store
from spack.parse import Token
-from spack.spec import Spec
-from spack.spec import SpecParseError, RedundantSpecError
-from spack.spec import AmbiguousHashError, InvalidHashError, NoSuchHashError
-from spack.spec import DuplicateArchitectureError
-from spack.spec import DuplicateDependencyError, DuplicateCompilerSpecError
-from spack.spec import SpecFilenameError, NoSuchSpecFileError
-from spack.spec import MultipleVersionError
+from spack.spec import (
+ AmbiguousHashError,
+ DuplicateArchitectureError,
+ DuplicateCompilerSpecError,
+ DuplicateDependencyError,
+ InvalidHashError,
+ MultipleVersionError,
+ NoSuchHashError,
+ NoSuchSpecFileError,
+ RedundantSpecError,
+ Spec,
+ SpecFilenameError,
+ SpecParseError,
+)
from spack.variant import DuplicateVariantError
-
# Sample output for a complex lexing.
complex_lex = [Token(sp.ID, 'mvapich_foo'),
Token(sp.DEP),
diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py
index 74ebf0a541..d1227ab74e 100644
--- a/lib/spack/spack/test/spec_yaml.py
+++ b/lib/spack/spack/test/spec_yaml.py
@@ -21,12 +21,10 @@ import spack.spec
import spack.util.spack_json as sjson
import spack.util.spack_yaml as syaml
import spack.version
-
from spack import repo
from spack.spec import Spec, save_dependency_spec_yamls
-from spack.util.spack_yaml import syaml_dict
from spack.util.mock_package import MockPackageMultiRepo
-
+from spack.util.spack_yaml import syaml_dict
if sys.version_info >= (3, 3):
from collections.abc import Iterable, Mapping # novm
diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py
index 3ebfcdf407..b337486e7f 100644
--- a/lib/spack/spack/test/stage.py
+++ b/lib/spack/spack/test/stage.py
@@ -4,13 +4,13 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Test that the Stage class works correctly."""
+import collections
import errno
+import getpass
import os
-import collections
import shutil
import stat
import tempfile
-import getpass
import pytest
@@ -19,9 +19,8 @@ from llnl.util.filesystem import mkdirp, partition_path, touch, working_dir
import spack.paths
import spack.stage
import spack.util.executable
-
from spack.resource import Resource
-from spack.stage import Stage, StageComposite, ResourceStage, DIYStage
+from spack.stage import DIYStage, ResourceStage, Stage, StageComposite
from spack.util.path import canonicalize_path
# The following values are used for common fetch and stage mocking fixtures:
diff --git a/lib/spack/spack/test/svn_fetch.py b/lib/spack/spack/test/svn_fetch.py
index 87e9779ca9..477aa5bc4a 100644
--- a/lib/spack/spack/test/svn_fetch.py
+++ b/lib/spack/spack/test/svn_fetch.py
@@ -7,16 +7,15 @@ import os
import pytest
-from llnl.util.filesystem import touch, working_dir, mkdirp
+from llnl.util.filesystem import mkdirp, touch, working_dir
-import spack.repo
import spack.config
+import spack.repo
+from spack.fetch_strategy import SvnFetchStrategy
from spack.spec import Spec
from spack.stage import Stage
-from spack.version import ver
-from spack.fetch_strategy import SvnFetchStrategy
from spack.util.executable import which
-
+from spack.version import ver
pytestmark = pytest.mark.skipif(
not which('svn') or not which('svnadmin'),
diff --git a/lib/spack/spack/test/tengine.py b/lib/spack/spack/test/tengine.py
index 00216a7fdc..c6098e40dd 100644
--- a/lib/spack/spack/test/tengine.py
+++ b/lib/spack/spack/test/tengine.py
@@ -5,9 +5,9 @@
import pytest
-import spack.tengine as tengine
-import spack.config
+import spack.config
+import spack.tengine as tengine
from spack.util.path import canonicalize_path
diff --git a/lib/spack/spack/test/test_activations.py b/lib/spack/spack/test/test_activations.py
index a05032d5a2..2156cc710d 100644
--- a/lib/spack/spack/test/test_activations.py
+++ b/lib/spack/spack/test/test_activations.py
@@ -8,11 +8,13 @@
"""
import os
+
import pytest
-import spack.spec
-import spack.package
from llnl.util.link_tree import MergeConflictError
+
+import spack.package
+import spack.spec
from spack.directory_layout import YamlDirectoryLayout
from spack.filesystem_view import YamlFilesystemView
from spack.repo import RepoPath
diff --git a/lib/spack/spack/test/test_suite.py b/lib/spack/spack/test/test_suite.py
index 4c16b2d2f6..3a11d6ab39 100644
--- a/lib/spack/spack/test/test_suite.py
+++ b/lib/spack/spack/test/test_suite.py
@@ -5,6 +5,7 @@
import os
import llnl.util.filesystem as fs
+
import spack.install_test
import spack.spec
diff --git a/lib/spack/spack/test/url_fetch.py b/lib/spack/spack/test/url_fetch.py
index 0c8ee3cf17..b466c40c06 100644
--- a/lib/spack/spack/test/url_fetch.py
+++ b/lib/spack/spack/test/url_fetch.py
@@ -5,21 +5,22 @@
import collections
import os
-import pytest
import sys
-from llnl.util.filesystem import working_dir, is_exe
+import pytest
+
import llnl.util.tty as tty
+from llnl.util.filesystem import is_exe, working_dir
-import spack.repo
import spack.config
import spack.fetch_strategy as fs
-from spack.spec import Spec
-from spack.stage import Stage
-from spack.version import ver
+import spack.repo
import spack.util.crypto as crypto
import spack.util.executable
+from spack.spec import Spec
+from spack.stage import Stage
from spack.util.executable import which
+from spack.version import ver
@pytest.fixture(params=list(crypto.hashes.keys()))
diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py
index ae6bdf76f2..82c301c213 100644
--- a/lib/spack/spack/test/url_parse.py
+++ b/lib/spack/spack/test/url_parse.py
@@ -8,12 +8,18 @@ based on its URL.
"""
import os
+
import pytest
-from spack.url import parse_name_offset, parse_version_offset
-from spack.url import parse_name_and_version, substitute_version
-from spack.url import strip_name_suffixes, strip_version_suffixes
-from spack.url import UndetectableVersionError
+from spack.url import (
+ UndetectableVersionError,
+ parse_name_and_version,
+ parse_name_offset,
+ parse_version_offset,
+ strip_name_suffixes,
+ strip_version_suffixes,
+ substitute_version,
+)
from spack.version import Version
diff --git a/lib/spack/spack/test/url_substitution.py b/lib/spack/spack/test/url_substitution.py
index 8fbfd48714..59dbace1a7 100644
--- a/lib/spack/spack/test/url_substitution.py
+++ b/lib/spack/spack/test/url_substitution.py
@@ -8,6 +8,7 @@
import os
import pytest
+
import spack.url
diff --git a/lib/spack/spack/test/util/editor.py b/lib/spack/spack/test/util/editor.py
index aa85323212..c36e7e6f6d 100644
--- a/lib/spack/spack/test/util/editor.py
+++ b/lib/spack/spack/test/util/editor.py
@@ -4,13 +4,13 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
from llnl.util.filesystem import set_executable
import spack.util.editor as ed
-
pytestmark = pytest.mark.usefixtures('working_env')
diff --git a/lib/spack/spack/test/util/environment.py b/lib/spack/spack/test/util/environment.py
index b7b6a0edea..233fc0ba84 100644
--- a/lib/spack/spack/test/util/environment.py
+++ b/lib/spack/spack/test/util/environment.py
@@ -4,8 +4,10 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Test Spack's environment utility functions."""
-import pytest
import os
+
+import pytest
+
import spack.util.environment as envutil
diff --git a/lib/spack/spack/test/util/executable.py b/lib/spack/spack/test/util/executable.py
index 9bfa9a408a..1b6ee0b295 100644
--- a/lib/spack/spack/test/util/executable.py
+++ b/lib/spack/spack/test/util/executable.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import sys
import os
+import sys
import pytest
diff --git a/lib/spack/spack/test/util/file_cache.py b/lib/spack/spack/test/util/file_cache.py
index c033ca49d9..3730300689 100644
--- a/lib/spack/spack/test/util/file_cache.py
+++ b/lib/spack/spack/test/util/file_cache.py
@@ -7,6 +7,7 @@
import os
import pytest
+
from spack.util.file_cache import FileCache
diff --git a/lib/spack/spack/test/util/util_gpg.py b/lib/spack/spack/test/util/util_gpg.py
index 82a410561c..31bbcd8e77 100644
--- a/lib/spack/spack/test/util/util_gpg.py
+++ b/lib/spack/spack/test/util/util_gpg.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+
import pytest
import spack.util.gpg
diff --git a/lib/spack/spack/test/util/util_url.py b/lib/spack/spack/test/util/util_url.py
index 07a055c572..3ac8708e70 100644
--- a/lib/spack/spack/test/util/util_url.py
+++ b/lib/spack/spack/test/util/util_url.py
@@ -6,6 +6,7 @@
"""Test Spack's URL handling utility functions."""
import os
import os.path
+
import spack.paths
import spack.util.url as url_util
diff --git a/lib/spack/spack/test/variant.py b/lib/spack/spack/test/variant.py
index 501d897321..efbe8501a4 100644
--- a/lib/spack/spack/test/variant.py
+++ b/lib/spack/spack/test/variant.py
@@ -4,18 +4,24 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import pytest
import numbers
-from spack.variant import Variant, SingleValuedVariant, VariantMap
-from spack.variant import MultiValuedVariant, BoolValuedVariant
-from spack.variant import UnsatisfiableVariantSpecError
-from spack.variant import InconsistentValidationError
-from spack.variant import MultipleValuesInExclusiveVariantError
-from spack.variant import InvalidVariantValueError, DuplicateVariantError
-from spack.variant import disjoint_sets
+import pytest
import spack.error
+from spack.variant import (
+ BoolValuedVariant,
+ DuplicateVariantError,
+ InconsistentValidationError,
+ InvalidVariantValueError,
+ MultipleValuesInExclusiveVariantError,
+ MultiValuedVariant,
+ SingleValuedVariant,
+ UnsatisfiableVariantSpecError,
+ Variant,
+ VariantMap,
+ disjoint_sets,
+)
class TestMultiValuedVariant(object):
diff --git a/lib/spack/spack/test/verification.py b/lib/spack/spack/test/verification.py
index cbeba8f635..e7d8193e8e 100644
--- a/lib/spack/spack/test/verification.py
+++ b/lib/spack/spack/test/verification.py
@@ -9,10 +9,10 @@ import shutil
import llnl.util.filesystem as fs
-import spack.util.spack_json as sjson
-import spack.verify
import spack.spec
import spack.store
+import spack.util.spack_json as sjson
+import spack.verify
def test_link_manifest_entry(tmpdir):
diff --git a/lib/spack/spack/test/views.py b/lib/spack/spack/test/views.py
index 18fd88b093..ac398a9989 100644
--- a/lib/spack/spack/test/views.py
+++ b/lib/spack/spack/test/views.py
@@ -5,9 +5,9 @@
import os
-from spack.spec import Spec
from spack.directory_layout import YamlDirectoryLayout
from spack.filesystem_view import YamlFilesystemView
+from spack.spec import Spec
def test_global_activation(install_mockery, mock_fetch):
diff --git a/lib/spack/spack/test/web.py b/lib/spack/spack/test/web.py
index d5f76632a4..c0ed098b2a 100644
--- a/lib/spack/spack/test/web.py
+++ b/lib/spack/spack/test/web.py
@@ -6,14 +6,15 @@ import os
import ordereddict_backport
import pytest
+
+import llnl.util.tty as tty
+
import spack.config
import spack.paths
-import spack.util.web
import spack.util.s3
+import spack.util.web
from spack.version import ver
-import llnl.util.tty as tty
-
def _create_url(relative_url):
web_data_path = os.path.join(spack.paths.test_path, 'data', 'web')
diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py
index 1fc0f2f522..770c5bd4c0 100644
--- a/lib/spack/spack/url.py
+++ b/lib/spack/spack/url.py
@@ -27,6 +27,7 @@ it's never been told about that version before.
"""
import os
import re
+
from six import StringIO
from six.moves.urllib.parse import urlsplit, urlunsplit
diff --git a/lib/spack/spack/user_environment.py b/lib/spack/spack/user_environment.py
index c4ea2b8ac2..005c6351b5 100644
--- a/lib/spack/spack/user_environment.py
+++ b/lib/spack/spack/user_environment.py
@@ -2,13 +2,13 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import sys
import os
+import sys
+import spack.build_environment as build_env
import spack.config
-import spack.util.prefix as prefix
import spack.util.environment as environment
-import spack.build_environment as build_env
+import spack.util.prefix as prefix
#: Environment variable name Spack uses to track individually loaded packages
spack_loaded_hashes_var = 'SPACK_LOADED_HASHES'
diff --git a/lib/spack/spack/util/classes.py b/lib/spack/spack/util/classes.py
index b6465c7581..262e3cad8a 100644
--- a/lib/spack/spack/util/classes.py
+++ b/lib/spack/spack/util/classes.py
@@ -5,12 +5,14 @@
# Need this because of spack.util.string
from __future__ import absolute_import
-from spack.util.naming import mod_to_class
-from llnl.util.lang import memoized, list_modules
-import llnl.util.tty as tty
import inspect
+import llnl.util.tty as tty
+from llnl.util.lang import list_modules, memoized
+
+from spack.util.naming import mod_to_class
+
__all__ = [
'list_classes'
]
diff --git a/lib/spack/spack/util/compression.py b/lib/spack/spack/util/compression.py
index 09d391e640..4068a145ff 100644
--- a/lib/spack/spack/util/compression.py
+++ b/lib/spack/spack/util/compression.py
@@ -3,9 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import re
import os
+import re
from itertools import product
+
from spack.util.executable import which
# Supported archive extensions.
diff --git a/lib/spack/spack/util/cpus.py b/lib/spack/spack/util/cpus.py
index 9fa10c87a8..c24309fc2d 100644
--- a/lib/spack/spack/util/cpus.py
+++ b/lib/spack/spack/util/cpus.py
@@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
import multiprocessing
+import os
def cpus_available():
diff --git a/lib/spack/spack/util/crypto.py b/lib/spack/spack/util/crypto.py
index 809b36ffea..549216a4c6 100644
--- a/lib/spack/spack/util/crypto.py
+++ b/lib/spack/spack/util/crypto.py
@@ -3,9 +3,9 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import sys
import hashlib
-from typing import Dict, Callable, Any # novm
+import sys
+from typing import Any, Callable, Dict # novm
import llnl.util.tty as tty
diff --git a/lib/spack/spack/util/debug.py b/lib/spack/spack/util/debug.py
index 290ad832f8..5acc49fcb2 100644
--- a/lib/spack/spack/util/debug.py
+++ b/lib/spack/spack/util/debug.py
@@ -9,10 +9,10 @@
a stack trace and drops the user into an interpreter.
"""
-import os
import code
-import traceback
+import os
import signal
+import traceback
def debug_handler(sig, frame):
diff --git a/lib/spack/spack/util/editor.py b/lib/spack/spack/util/editor.py
index 9b0081b19a..400c4eb63a 100644
--- a/lib/spack/spack/util/editor.py
+++ b/lib/spack/spack/util/editor.py
@@ -20,7 +20,6 @@ import llnl.util.tty as tty
import spack.config
from spack.util.executable import which_string
-
#: editors to try if VISUAL and EDITOR are not set
_default_editors = ['vim', 'vi', 'emacs', 'nano']
diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py
index d015ee4e97..f33e3c0b8f 100644
--- a/lib/spack/spack/util/environment.py
+++ b/lib/spack/spack/util/environment.py
@@ -9,21 +9,20 @@ import contextlib
import inspect
import json
import os
+import os.path
import platform
import re
import socket
import sys
-import os.path
import six
+from six.moves import cPickle
+from six.moves import shlex_quote as cmd_quote
import llnl.util.tty as tty
-import spack.util.executable as executable
-
from llnl.util.lang import dedupe
-from six.moves import shlex_quote as cmd_quote
-from six.moves import cPickle
+import spack.util.executable as executable
system_paths = ['/', '/usr', '/usr/local']
suffixes = ['bin', 'bin64', 'include', 'lib', 'lib64']
@@ -159,8 +158,8 @@ def get_host_environment():
"""Return a dictionary (lookup) with host information (not including the
os.environ).
"""
- import spack.spec
import spack.architecture as architecture
+ import spack.spec
arch = architecture.Arch(
architecture.platform(), 'default_os', 'default_target')
arch_spec = spack.spec.Spec('arch=%s' % arch)
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index c1e90ff25f..084ca48147 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import sys
import os
import re
import shlex
import subprocess
+import sys
+
from six import string_types, text_type
import llnl.util.tty as tty
@@ -123,6 +124,7 @@ class Executable(object):
env.update(self.default_env)
from spack.util.environment import EnvironmentModifications # no cycle
+
# Apply env argument
if isinstance(env_arg, EnvironmentModifications):
env_arg.apply_modifications(env)
diff --git a/lib/spack/spack/util/file_permissions.py b/lib/spack/spack/util/file_permissions.py
index 7ed974816e..9a510ef6c8 100644
--- a/lib/spack/spack/util/file_permissions.py
+++ b/lib/spack/spack/util/file_permissions.py
@@ -5,7 +5,9 @@
import os
import stat as st
+
import llnl.util.filesystem as fs
+
import spack.package_prefs as pp
from spack.error import SpackError
diff --git a/lib/spack/spack/util/gpg.py b/lib/spack/spack/util/gpg.py
index e224c2978f..787f205a13 100644
--- a/lib/spack/spack/util/gpg.py
+++ b/lib/spack/spack/util/gpg.py
@@ -13,7 +13,6 @@ import spack.paths
import spack.util.executable
import spack.version
-
#: Executable instance for "gpg", initialized lazily
GPG = None
#: Executable instance for "gpgconf", initialized lazily
diff --git a/lib/spack/spack/util/lock.py b/lib/spack/spack/util/lock.py
index 2f465f590a..2f9839b0e2 100644
--- a/lib/spack/spack/util/lock.py
+++ b/lib/spack/spack/util/lock.py
@@ -8,12 +8,13 @@ import os
import stat
import llnl.util.lock
-from llnl.util.lock import * # noqa
import spack.config
import spack.error
import spack.paths
+from llnl.util.lock import * # noqa
+
class Lock(llnl.util.lock.Lock): # type: ignore[no-redef]
"""Lock that can be disabled.
diff --git a/lib/spack/spack/util/log_parse.py b/lib/spack/spack/util/log_parse.py
index 7973bfd6b0..ccfde6d279 100644
--- a/lib/spack/spack/util/log_parse.py
+++ b/lib/spack/spack/util/log_parse.py
@@ -6,9 +6,9 @@
from __future__ import print_function
import sys
-from six import StringIO
-from ctest_log_parser import CTestLogParser, BuildError, BuildWarning
+from ctest_log_parser import BuildError, BuildWarning, CTestLogParser
+from six import StringIO
import llnl.util.tty as tty
from llnl.util.tty.color import cescape, colorize
diff --git a/lib/spack/spack/util/mock_package.py b/lib/spack/spack/util/mock_package.py
index 847177ae05..d8b3ec468b 100644
--- a/lib/spack/spack/util/mock_package.py
+++ b/lib/spack/spack/util/mock_package.py
@@ -7,8 +7,8 @@
import ordereddict_backport
-import spack.util.naming
import spack.provider_index
+import spack.util.naming
from spack.dependency import Dependency
from spack.spec import Spec
from spack.version import Version
diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py
index 338e724c51..d8c3ec8d14 100644
--- a/lib/spack/spack/util/module_cmd.py
+++ b/lib/spack/spack/util/module_cmd.py
@@ -7,15 +7,16 @@
This module contains routines related to the module command for accessing and
parsing environment modules.
"""
-import subprocess
-import os
-import sys
import json
+import os
import re
+import subprocess
+import sys
-import spack
import llnl.util.tty as tty
+import spack
+
# This list is not exhaustive. Currently we only use load and unload
# If we need another option that changes the environment, add it here.
module_change_commands = ['load', 'swap', 'unload', 'purge', 'use', 'unuse']
diff --git a/lib/spack/spack/util/naming.py b/lib/spack/spack/util/naming.py
index db5d1d4907..a1ba2fd5aa 100644
--- a/lib/spack/spack/util/naming.py
+++ b/lib/spack/spack/util/naming.py
@@ -5,9 +5,11 @@
# Need this because of spack.util.string
from __future__ import absolute_import
-import string
+
import itertools
import re
+import string
+
from six import StringIO
import spack.error
diff --git a/lib/spack/spack/util/package_hash.py b/lib/spack/spack/util/package_hash.py
index 462f43d223..05d7abe056 100644
--- a/lib/spack/spack/util/package_hash.py
+++ b/lib/spack/spack/util/package_hash.py
@@ -6,10 +6,10 @@
import ast
import hashlib
-import spack.repo
-import spack.package
import spack.directives
import spack.error
+import spack.package
+import spack.repo
import spack.spec
import spack.util.naming
diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py
index 0735133b35..b13814f4e3 100644
--- a/lib/spack/spack/util/path.py
+++ b/lib/spack/spack/util/path.py
@@ -7,9 +7,9 @@
TODO: this is really part of spack.config. Consolidate it.
"""
+import getpass
import os
import re
-import getpass
import subprocess
import tempfile
diff --git a/lib/spack/spack/util/pattern.py b/lib/spack/spack/util/pattern.py
index fc4b324b17..655172886b 100644
--- a/lib/spack/spack/util/pattern.py
+++ b/lib/spack/spack/util/pattern.py
@@ -3,11 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import inspect
import functools
+import inspect
import sys
-
if sys.version_info >= (3, 3):
from collections.abc import MutableSequence # novm
else:
diff --git a/lib/spack/spack/util/spack_json.py b/lib/spack/spack/util/spack_json.py
index 62fd9ca824..653c3b5dda 100644
--- a/lib/spack/spack/util/spack_json.py
+++ b/lib/spack/spack/util/spack_json.py
@@ -4,10 +4,10 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Simple wrapper around JSON to guarantee consistent use of load/dump. """
-import sys
import json
-from six import string_types
-from six import iteritems
+import sys
+
+from six import iteritems, string_types
import spack.error
diff --git a/lib/spack/spack/util/spack_yaml.py b/lib/spack/spack/util/spack_yaml.py
index 24eea88b77..a67b6491f8 100644
--- a/lib/spack/spack/util/spack_yaml.py
+++ b/lib/spack/spack/util/spack_yaml.py
@@ -17,17 +17,15 @@ import re
import sys
from typing import List # novm
-from ordereddict_backport import OrderedDict
-from six import string_types, StringIO
-
import ruamel.yaml as yaml
-from ruamel.yaml import RoundTripLoader, RoundTripDumper
+from ordereddict_backport import OrderedDict
+from ruamel.yaml import RoundTripDumper, RoundTripLoader
+from six import StringIO, string_types
-from llnl.util.tty.color import colorize, clen, cextra
+from llnl.util.tty.color import cextra, clen, colorize
import spack.error
-
if sys.version_info >= (3, 3):
from collections.abc import Mapping # novm
else:
diff --git a/lib/spack/spack/util/timer.py b/lib/spack/spack/util/timer.py
index 077b81222f..9dbc7551ea 100644
--- a/lib/spack/spack/util/timer.py
+++ b/lib/spack/spack/util/timer.py
@@ -9,9 +9,10 @@
a stack trace and drops the user into an interpreter.
"""
-import spack.util.spack_json as sjson
-import time
import sys
+import time
+
+import spack.util.spack_json as sjson
class Timer(object):
diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py
index d4febac3e3..4787e33dd6 100644
--- a/lib/spack/spack/util/web.py
+++ b/lib/spack/spack/util/web.py
@@ -18,10 +18,11 @@ import traceback
import six
from six.moves.urllib.error import URLError
-from six.moves.urllib.request import urlopen, Request
+from six.moves.urllib.request import Request, urlopen
-from llnl.util.filesystem import mkdirp
+import llnl.util.lang
import llnl.util.tty as tty
+from llnl.util.filesystem import mkdirp
import spack.cmd
import spack.config
@@ -30,13 +31,11 @@ import spack.url
import spack.util.crypto
import spack.util.s3 as s3_util
import spack.util.url as url_util
-import llnl.util.lang
-
from spack.util.compression import ALLOWED_ARCHIVE_TYPES
if sys.version_info < (3, 0):
# Python 2 had these in the HTMLParser package.
- from HTMLParser import HTMLParser, HTMLParseError # novm
+ from HTMLParser import HTMLParseError, HTMLParser # novm
else:
# In Python 3, things moved to html.parser
from html.parser import HTMLParser
diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py
index 0929a5ea44..9b7d8779fe 100644
--- a/lib/spack/spack/variant.py
+++ b/lib/spack/spack/variant.py
@@ -11,20 +11,21 @@ import functools
import inspect
import itertools
import re
-from six import StringIO
import sys
+from six import StringIO
+
if sys.version_info >= (3, 5):
from collections.abc import Sequence # novm
else:
from collections import Sequence
-import llnl.util.tty.color
import llnl.util.lang as lang
+import llnl.util.tty.color
-from spack.util.string import comma_or
import spack.directives
import spack.error as error
+from spack.util.string import comma_or
special_variant_values = [None, 'none', '*']
diff --git a/lib/spack/spack/verify.py b/lib/spack/spack/verify.py
index b8d76e03e2..37c574875d 100644
--- a/lib/spack/spack/verify.py
+++ b/lib/spack/spack/verify.py
@@ -2,17 +2,17 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import os
-import hashlib
import base64
+import hashlib
+import os
import sys
import llnl.util.tty as tty
-import spack.util.spack_json as sjson
-import spack.util.file_permissions as fp
-import spack.store
import spack.filesystem_view
+import spack.store
+import spack.util.file_permissions as fp
+import spack.util.spack_json as sjson
def compute_hash(path):
diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py
index 251c86b184..0ed1239216 100644
--- a/lib/spack/spack/version.py
+++ b/lib/spack/spack/version.py
@@ -24,16 +24,16 @@ be called on any of the types::
intersection
concrete
"""
-import re
import numbers
+import re
from bisect import bisect_left
from functools import wraps
+
from six import string_types
import spack.error
from spack.util.spack_yaml import syaml_dict
-
__all__ = ['Version', 'VersionRange', 'VersionList', 'ver']
# Valid version characters