7
7
import sys
8
8
import tempfile
9
9
import time
10
+ from collections .abc import Sequence
10
11
from enum import Enum
11
12
from pathlib import Path
12
13
from types import TracebackType
@@ -753,7 +754,7 @@ def diff_env(before: List[str], after: List[str], ignore: str):
753
754
assert not diff , "Environment should not be modified"
754
755
755
756
756
- class CompletionResult (Iterable [str ]):
757
+ class CompletionResult (Sequence [str ]):
757
758
"""
758
759
Class to hold completion results.
759
760
"""
@@ -773,6 +774,9 @@ def startswith(self, prefix: str) -> bool:
773
774
def _items (self ) -> List [str ]:
774
775
return sorted ([x .strip () for x in self .output .strip ().splitlines ()])
775
776
777
+ def __getitem__ (self , i ) -> str :
778
+ return self ._items ()[i ]
779
+
776
780
def __eq__ (self , expected : object ) -> bool :
777
781
"""
778
782
Returns True if completion contains expected items, and no others.
@@ -788,7 +792,7 @@ def __eq__(self, expected: object) -> bool:
788
792
expiter = expected
789
793
return self ._items () == sorted (expiter )
790
794
791
- def __contains__ (self , item : str ) -> bool :
795
+ def __contains__ (self , item : object ) -> bool :
792
796
return item in self ._items ()
793
797
794
798
def __iter__ (self ) -> Iterator [str ]:
0 commit comments