summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/llnl/util/lang.py11
-rw-r--r--lib/spack/spack/cmd/buildcache.py2
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index d0d9400c32..736013fe58 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -843,20 +843,19 @@ def uniq(sequence):
return uniq_list
-def elide_list(line_list, max_num=10):
+def elide_list(line_list: List[str], max_num: int = 10) -> List[str]:
"""Takes a long list and limits it to a smaller number of elements,
replacing intervening elements with '...'. For example::
- elide_list([1,2,3,4,5,6], 4)
+ elide_list(["1", "2", "3", "4", "5", "6"], 4)
gives::
- [1, 2, 3, '...', 6]
+ ["1", "2", "3", "...", "6"]
"""
if len(line_list) > max_num:
- return line_list[: max_num - 1] + ["..."] + line_list[-1:]
- else:
- return line_list
+ return [*line_list[: max_num - 1], "...", line_list[-1]]
+ return line_list
@contextlib.contextmanager
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index fb0ffbd78f..7839f31512 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -460,7 +460,7 @@ def push_fn(args):
"The following {} specs were skipped as they already exist in the buildcache:\n"
" {}\n"
" Use --force to overwrite them.".format(
- len(skipped), ", ".join(elide_list(skipped, 5))
+ len(skipped), ", ".join(elide_list([_format_spec(s) for s in skipped], 5))
)
)