Show More
@@ -786,19 +786,23 b' def match_dict_keys(keys: List[Union[str, bytes, Tuple[Union[str, bytes]]]], pre' | |||||
786 | for k, pt in zip(key, prefix_tuple): |
|
786 | for k, pt in zip(key, prefix_tuple): | |
787 | if k != pt: |
|
787 | if k != pt: | |
788 | return False |
|
788 | return False | |
789 |
|
|
789 | else: | |
|
790 | return True | |||
|
791 | ||||
|
792 | filtered_keys:List[Union[str,bytes]] = [] | |||
|
793 | def _add_to_filtered_keys(key): | |||
|
794 | if isinstance(key, (str, bytes)): | |||
|
795 | filtered_keys.append(key) | |||
790 |
|
796 | |||
791 | new_keys = [] |
|
|||
792 | for k in keys: |
|
797 | for k in keys: | |
793 |
if isinstance(k, |
|
798 | if isinstance(k, tuple): | |
794 | new_keys.append(k) |
|
799 | if filter_by_prefix_tuple(k): | |
795 | elif isinstance(k, tuple) and filter_by_prefix_tuple(k): |
|
800 | _add_to_filtered_keys(k[Nprefix]) | |
796 | new_keys.append(k[Nprefix]) |
|
801 | else: | |
|
802 | _add_to_filtered_keys(k) | |||
797 |
|
803 | |||
798 | keys = new_keys |
|
|||
799 | if not prefix: |
|
804 | if not prefix: | |
800 | return '', 0, [repr(k) for k in keys |
|
805 | return '', 0, [repr(k) for k in filtered_keys] | |
801 | if isinstance(k, (str, bytes))] |
|
|||
802 | quote_match = re.search('["\']', prefix) |
|
806 | quote_match = re.search('["\']', prefix) | |
803 | assert quote_match is not None # silence mypy |
|
807 | assert quote_match is not None # silence mypy | |
804 | quote = quote_match.group() |
|
808 | quote = quote_match.group() | |
@@ -814,7 +818,7 b' def match_dict_keys(keys: List[Union[str, bytes, Tuple[Union[str, bytes]]]], pre' | |||||
814 | token_prefix = token_match.group() |
|
818 | token_prefix = token_match.group() | |
815 |
|
819 | |||
816 | matched:List[str] = [] |
|
820 | matched:List[str] = [] | |
817 | for key in keys: |
|
821 | for key in filtered_keys: | |
818 | try: |
|
822 | try: | |
819 | if not key.startswith(prefix_str): |
|
823 | if not key.startswith(prefix_str): | |
820 | continue |
|
824 | continue |
General Comments 0
You need to be logged in to leave comments.
Login now