summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2017-10-23 14:20:39 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2017-10-24 10:05:36 +0200
commit0bb1eb32f2c002b4b9deb44815192b4299432fa8 (patch)
treefe6bd2ed07d93dae9bf49c52205a91c2e1a6a3e8 /lib
parent7dd79094b05172cfcd2b594326eb22bf8e3c83cd (diff)
downloadspack-0bb1eb32f2c002b4b9deb44815192b4299432fa8.tar.gz
spack-0bb1eb32f2c002b4b9deb44815192b4299432fa8.tar.bz2
spack-0bb1eb32f2c002b4b9deb44815192b4299432fa8.tar.xz
spack-0bb1eb32f2c002b4b9deb44815192b4299432fa8.zip
fix bugs found with stricter flake8 rules
- When you don't use wildcards, flake8 will find places where you used an undefined name. - This commit has all the bugfixes resulting from this static check.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/tty/colify.py2
-rw-r--r--lib/spack/spack/cmd/mirror.py2
-rw-r--r--lib/spack/spack/fetch_strategy.py4
-rw-r--r--lib/spack/spack/main.py4
-rw-r--r--lib/spack/spack/package.py4
-rw-r--r--lib/spack/spack/patch.py3
-rw-r--r--lib/spack/spack/test/database.py7
7 files changed, 17 insertions, 9 deletions
diff --git a/lib/spack/llnl/util/tty/colify.py b/lib/spack/llnl/util/tty/colify.py
index 66e9f7abfb..b04775b4f1 100644
--- a/lib/spack/llnl/util/tty/colify.py
+++ b/lib/spack/llnl/util/tty/colify.py
@@ -188,7 +188,7 @@ def colify(elts, **options):
elif method == "uniform":
config = config_uniform_cols(elts, console_cols, padding, cols)
else:
- raise ValueError("method must be one of: " + allowed_methods)
+ raise ValueError("method must be either 'variable' or 'uniform'")
cols = config.cols
rows = (len(elts) + cols - 1) // cols
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 60dd372432..6193c9fa92 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -155,7 +155,7 @@ def _read_specs_from_file(filename):
s.package
specs.append(s)
except SpackError as e:
- tty.die("Parse error in %s, line %d:" % (args.file, i + 1),
+ tty.die("Parse error in %s, line %d:" % (filename, i + 1),
">>> " + string, str(e))
return specs
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index dc405f63d8..4ab76c8d2a 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -449,7 +449,7 @@ class VCSFetchStrategy(FetchStrategy):
# Ensure that there's only one of the rev_types
if sum(k in kwargs for k in rev_types) > 1:
- raise FetchStrategyError(
+ raise ValueError(
"Supply only one of %s to fetch with %s" % (
comma_or(rev_types), name
))
@@ -969,7 +969,7 @@ def from_list_url(pkg):
return URLFetchStrategy(url=url_from_list, digest=digest)
except KeyError:
tty.msg("Can not find version %s in url_list" %
- self.version)
+ pkg.version)
except:
tty.msg("Could not determine url from list_url.")
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 142d23d42a..775873df23 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -93,8 +93,8 @@ def set_working_dir():
try:
spack.spack_working_dir = os.getcwd()
except OSError:
- os.chdir(spack_prefix)
- spack.spack_working_dir = spack_prefix
+ os.chdir(spack.spack_prefix)
+ spack.spack_working_dir = spack.spack_prefix
def add_all_commands(parser):
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index c4b8d53fa5..89b3ac9b19 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1878,7 +1878,7 @@ class PackageBase(with_metaclass(PackageMeta, object)):
"""Try to find remote versions of this package using the
list_url and any other URLs described in the package file."""
if not self.all_urls:
- raise VersionFetchError(self.__class__)
+ raise spack.util.web.VersionFetchError(self.__class__)
try:
return spack.util.web.find_versions_of_archive(
@@ -2022,7 +2022,7 @@ def dump_packages(spec, path):
source_repo = spack.repository.Repo(source_repo_root)
source_pkg_dir = source_repo.dirname_for_package_name(
node.name)
- except RepoError:
+ except spack.repository.RepoError:
tty.warn("Warning: Couldn't copy in provenance for %s" %
node.name)
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py
index 028f98f3a1..fed577771f 100644
--- a/lib/spack/spack/patch.py
+++ b/lib/spack/spack/patch.py
@@ -187,7 +187,8 @@ class UrlPatch(Patch):
# for a compressed archive, Need to check the patch sha256 again
# and the patch is in a directory, not in the same place
if self.archive_sha256:
- if not Checker(self.sha256).check(self.path):
+ checker = Checker(self.sha256)
+ if not checker.check(self.path):
raise fs.ChecksumError(
"sha256 checksum failed for %s" % self.path,
"Expected %s but got %s" % (self.sha256, checker.sum))
diff --git a/lib/spack/spack/test/database.py b/lib/spack/spack/test/database.py
index 98cc4a214a..a1b2213f18 100644
--- a/lib/spack/spack/test/database.py
+++ b/lib/spack/spack/test/database.py
@@ -105,6 +105,13 @@ def _check_db_sanity(install_db):
_check_merkleiness()
+def _mock_install(spec):
+ s = spack.spec.Spec(spec)
+ s.concretize()
+ pkg = spack.repo.get(s)
+ pkg.do_install(fake=True)
+
+
def _mock_remove(spec):
specs = spack.store.db.query(spec)
assert len(specs) == 1