Skip to content

Commit

Permalink
fix: collect with no patterns properly defers to the main iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Jun 16, 2021
1 parent 8ad92bf commit 3c6000a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tokenstream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ def collect(
def collect(self, *patterns: TokenPattern) -> Iterator[Any]:
"""Collect tokens matching the given patterns."""
if not patterns:
return self
yield from self
return

while token := self.peek():
matches = [token if token.match(pattern) else None for pattern in patterns]
Expand Down

0 comments on commit 3c6000a

Please sign in to comment.