From 1571d6240be4ef0757244295c9a60469bfb600f0 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 23 Dec 2020 15:15:41 -0800 Subject: style: ensure that all packages pass `spack style -a` - fix trailing whitespace and other issues uncovered by better flake8 checking. - fix extra whitespace printed by `spack style` command --- lib/spack/spack/cmd/info.py | 2 +- lib/spack/spack/cmd/style.py | 2 ++ lib/spack/spack/test/cmd/dependencies.py | 14 ++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py index fa674317ab..9c9c0faee2 100644 --- a/lib/spack/spack/cmd/info.py +++ b/lib/spack/spack/cmd/info.py @@ -111,7 +111,7 @@ class VariantFormatter(object): yield ' None' else: yield ' ' + self.fmt % self.headers - underline = tuple([l * "=" for l in self.column_widths]) + underline = tuple([w * "=" for w in self.column_widths]) yield ' ' + self.fmt % underline yield '' for k, v in sorted(self.variants.items()): diff --git a/lib/spack/spack/cmd/style.py b/lib/spack/spack/cmd/style.py index 62a7b72d8e..9b72849c28 100644 --- a/lib/spack/spack/cmd/style.py +++ b/lib/spack/spack/cmd/style.py @@ -183,6 +183,8 @@ def rewrite_and_print_output( ) for line in output.split("\n"): + if not line: + continue print( re_obj.sub( cwd_relative, diff --git a/lib/spack/spack/test/cmd/dependencies.py b/lib/spack/spack/test/cmd/dependencies.py index 05d0556936..8518f2e80d 100644 --- a/lib/spack/spack/test/cmd/dependencies.py +++ b/lib/spack/spack/test/cmd/dependencies.py @@ -51,8 +51,11 @@ def test_direct_installed_dependencies(mock_packages, database): with color_when(False): out = dependencies('--installed', 'mpileaks^mpich') - lines = [l for l in out.strip().split('\n') if not l.startswith('--')] - hashes = set([re.split(r'\s+', l)[0] for l in lines]) + lines = [ + line for line in out.strip().split('\n') + if not line.startswith('--') + ] + hashes = set([re.split(r'\s+', line)[0] for line in lines]) expected = set([spack.store.db.query_one(s).dag_hash(7) for s in ['mpich', 'callpath^mpich']]) @@ -65,8 +68,11 @@ def test_transitive_installed_dependencies(mock_packages, database): with color_when(False): out = dependencies('--installed', '--transitive', 'mpileaks^zmpi') - lines = [l for l in out.strip().split('\n') if not l.startswith('--')] - hashes = set([re.split(r'\s+', l)[0] for l in lines]) + lines = [ + line for line in out.strip().split('\n') + if not line.startswith('--') + ] + hashes = set([re.split(r'\s+', line)[0] for line in lines]) expected = set([spack.store.db.query_one(s).dag_hash(7) for s in ['zmpi', 'callpath^zmpi', 'fake', -- cgit v1.2.3-60-g2f50