Check the "rule of 3" which prevents an open delimiter from pairing with an ambiguous one. The original lengths of the delimiter must be used, not what is left of them after partial pairing.
(opener: int, closer: int)
| 814 | |
| 815 | @staticmethod |
| 816 | def rule_of_3(opener: int, closer: int) -> bool: |
| 817 | """ |
| 818 | Check the "rule of 3" which prevents an open delimiter from pairing with an ambiguous one. |
| 819 | |
| 820 | The original lengths of the delimiter must be used, not what is left of them after partial pairing. |
| 821 | """ |
| 822 | |
| 823 | return (opener + closer) % 3 == 0 and (opener % 3 != 0 or closer % 3 != 0) |
| 824 | |
| 825 | def get_match(self, data: str, start: int) -> re.Match[str] | None: |
| 826 | """Get match.""" |