Check if any result includes any completions.
(result: MatcherResult)
| 716 | |
| 717 | |
| 718 | def has_any_completions(result: MatcherResult) -> bool: |
| 719 | """Check if any result includes any completions.""" |
| 720 | completions = result["completions"] |
| 721 | if _is_sizable(completions): |
| 722 | return len(completions) != 0 |
| 723 | if _is_iterator(completions): |
| 724 | try: |
| 725 | old_iterator = completions |
| 726 | first = next(old_iterator) |
| 727 | result["completions"] = cast( |
| 728 | Iterator[SimpleCompletion], |
| 729 | itertools.chain([first], old_iterator), |
| 730 | ) |
| 731 | return True |
| 732 | except StopIteration: |
| 733 | return False |
| 734 | raise ValueError( |
| 735 | "Completions returned by matcher need to be an Iterator or a Sizable" |
| 736 | ) |
| 737 | |
| 738 | |
| 739 | def completion_matcher( |
no test coverage detected
searching dependent graphs…