diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2023-11-30 20:31:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 20:31:03 +0100 |
commit | 6ff07c7753781b80bfa4a94151506176b7350364 (patch) | |
tree | 48a9523146baf593604d229eb1894ed3c245d18b /lib | |
parent | d874c6d79cb177d865134e30d17761650cc0866b (diff) | |
download | spack-6ff07c7753781b80bfa4a94151506176b7350364.tar.gz spack-6ff07c7753781b80bfa4a94151506176b7350364.tar.bz2 spack-6ff07c7753781b80bfa4a94151506176b7350364.tar.xz spack-6ff07c7753781b80bfa4a94151506176b7350364.zip |
Fix issue with latest mypy (#41363)
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: |