(self, line: Line)
| 896 | class="st">""" |
| 897 | |
| 898 | def do_match(self, line: Line) -> TMatchResult: |
| 899 | LL = line.leaves |
| 900 | |
| 901 | is_valid_index = is_valid_index_factory(LL) |
| 902 | |
| 903 | string_indices = [] |
| 904 | |
| 905 | idx = -1 |
| 906 | while True: |
| 907 | idx += 1 |
| 908 | if idx >= len(LL): |
| 909 | break |
| 910 | leaf = LL[idx] |
| 911 | |
| 912 | class="cm"># Should be a string... |
| 913 | if leaf.type != token.STRING: |
| 914 | continue |
| 915 | |
| 916 | class="cm"># If this is a class="st">"pointless" string... |
| 917 | if ( |
| 918 | leaf.parent |
| 919 | and leaf.parent.parent |
| 920 | and leaf.parent.parent.type == syms.simple_stmt |
| 921 | ): |
| 922 | continue |
| 923 | |
| 924 | class="cm"># Should be preceded by a non-empty LPAR... |
| 925 | if ( |
| 926 | not is_valid_index(idx - 1) |
| 927 | or LL[idx - 1].type != token.LPAR |
| 928 | or is_empty_lpar(LL[idx - 1]) |
| 929 | ): |
| 930 | continue |
| 931 | |
| 932 | class="cm"># That LPAR should NOT be preceded by a colon (which could be a |
| 933 | class="cm"># dictionary value), function name, or a closing bracket (which |
| 934 | class="cm"># could be a function returning a function or a list/dictionary |
| 935 | class="cm"># containing a function)... |
| 936 | if is_valid_index(idx - 2) and ( |
| 937 | LL[idx - 2].type == token.COLON |
| 938 | or LL[idx - 2].type == token.NAME |
| 939 | or LL[idx - 2].type in CLOSING_BRACKETS |
| 940 | ): |
| 941 | continue |
| 942 | |
| 943 | string_idx = idx |
| 944 | |
| 945 | class="cm"># Skip the string trailer, if one exists. |
| 946 | string_parser = StringParser() |
| 947 | next_idx = string_parser.parse(LL, string_idx) |
| 948 | |
| 949 | class="cm"># if the leaves in the parsed string include a PERCENT, we need to |
| 950 | class="cm"># make sure the initial LPAR is NOT preceded by an operator with |
| 951 | class="cm"># higher or equal precedence to PERCENT |
| 952 | if is_valid_index(idx - 2): |
| 953 | class="cm"># mypy can't quite follow unless we name this |
| 954 | before_lpar = LL[idx - 2] |
| 955 | if token.PERCENT in {leaf.type for leaf in LL[idx - 1 : next_idx]} and ( |
nothing calls this directly
no test coverage detected