diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/parser.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/spack/spack/parser.py b/lib/spack/spack/parser.py index c69918b419..b0a8d8ad83 100644 --- a/lib/spack/spack/parser.py +++ b/lib/spack/spack/parser.py @@ -206,11 +206,15 @@ def tokenize(text: str) -> Iterator[Token]: scanner = ALL_TOKENS.scanner(text) # type: ignore[attr-defined] match: Optional[Match] = None for match in iter(scanner.match, None): + # The following two assertions are to help mypy + msg = ( + "unexpected value encountered during parsing. Please submit a bug report " + "at https://github.com/spack/spack/issues/new/choose" + ) + assert match is not None, msg + assert match.lastgroup is not None, msg yield Token( - TokenType.__members__[match.lastgroup], # type: ignore[attr-defined] - match.group(), # type: ignore[attr-defined] - match.start(), # type: ignore[attr-defined] - match.end(), # type: ignore[attr-defined] + TokenType.__members__[match.lastgroup], match.group(), match.start(), match.end() ) if match is None and not text: |