Skip to content

Commit

Permalink
fix: handle pattern explanation with no pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Jul 22, 2021
1 parent d530760 commit 1de098b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tokenstream/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def explain_patterns(patterns: Sequence[TokenPattern]) -> str:
pattern if isinstance(pattern, str) else f"{pattern[0]} {pattern[1]!r}"
for pattern in patterns
]
if not token_types:
return "nothing"
if len(token_types) == 1:
return token_types[0]
*head, before_last, last = token_types
Expand Down

0 comments on commit 1de098b

Please sign in to comment.