diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py index b1e174930b7..5cee932504b 100644 --- a/lib/spack/spack/cmd/__init__.py +++ b/lib/spack/spack/cmd/__init__.py @@ -171,7 +171,9 @@ def quote_kvp(string: str) -> str: def parse_specs( - args: Union[str, List[str]], concretize: bool = False, tests: bool = False + args: Union[str, List[str]], + concretize: bool = False, + tests: spack.concretize.TestsType = False, ) -> List[spack.spec.Spec]: """Convenience function for parsing arguments from specs. Handles common exceptions and dies if there are errors. @@ -183,11 +185,13 @@ def parse_specs( if not concretize: return specs - to_concretize = [(s, None) for s in specs] + to_concretize: List[spack.concretize.SpecPairInput] = [(s, None) for s in specs] return _concretize_spec_pairs(to_concretize, tests=tests) -def _concretize_spec_pairs(to_concretize, tests=False): +def _concretize_spec_pairs( + to_concretize: List[spack.concretize.SpecPairInput], tests: spack.concretize.TestsType = False +) -> List[spack.spec.Spec]: """Helper method that concretizes abstract specs from a list of abstract,concrete pairs. Any spec with a concrete spec associated with it will concretize to that spec. Any spec @@ -198,7 +202,7 @@ def _concretize_spec_pairs(to_concretize, tests=False): # Special case for concretizing a single spec if len(to_concretize) == 1: abstract, concrete = to_concretize[0] - return [concrete or abstract.concretized()] + return [concrete or abstract.concretized(tests=tests)] # Special case if every spec is either concrete or has an abstract hash if all( diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 89180d5e7fb..468e0309ecf 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -5,7 +5,7 @@ import sys import time from contextlib import contextmanager -from typing import Iterable, Optional, Sequence, Tuple, Union +from typing import Iterable, List, Optional, Sequence, Tuple, Union import llnl.util.tty as tty @@ -35,6 +35,7 @@ def enable_compiler_existence_check(): CHECK_COMPILER_EXISTENCE = saved +SpecPairInput = Tuple[Spec, Optional[Spec]] SpecPair = Tuple[Spec, Spec] SpecLike = Union[Spec, str] TestsType = Union[bool, Iterable[str]] @@ -59,8 +60,8 @@ def concretize_specs_together( def concretize_together( - spec_list: Sequence[SpecPair], tests: TestsType = False -) -> Sequence[SpecPair]: + spec_list: Sequence[SpecPairInput], tests: TestsType = False +) -> List[SpecPair]: """Given a number of specs as input, tries to concretize them together. Args: @@ -76,8 +77,8 @@ def concretize_together( def concretize_together_when_possible( - spec_list: Sequence[SpecPair], tests: TestsType = False -) -> Sequence[SpecPair]: + spec_list: Sequence[SpecPairInput], tests: TestsType = False +) -> List[SpecPair]: """Given a number of specs as input, tries to concretize them together to the extent possible. See documentation for ``unify: when_possible`` concretization for the precise definition of @@ -113,8 +114,8 @@ def concretize_together_when_possible( def concretize_separately( - spec_list: Sequence[SpecPair], tests: TestsType = False -) -> Sequence[SpecPair]: + spec_list: Sequence[SpecPairInput], tests: TestsType = False +) -> List[SpecPair]: """Concretizes the input specs separately from each other. Args: