Check if the depth of brackets in the list of tokens drops below 0
(tokens: List[tokenize.TokenInfo])
| 644 | |
| 645 | |
| 646 | def has_sunken_brackets(tokens: List[tokenize.TokenInfo]): |
| 647 | """Check if the depth of brackets in the list of tokens drops below 0""" |
| 648 | parenlev = 0 |
| 649 | for token in tokens: |
| 650 | if token.string in {"(", "[", "{"}: |
| 651 | parenlev += 1 |
| 652 | elif token.string in {")", "]", "}"}: |
| 653 | parenlev -= 1 |
| 654 | if parenlev < 0: |
| 655 | return True |
| 656 | return False |
| 657 | |
| 658 | # Arbitrary limit to prevent getting stuck in infinite loops |
| 659 | TRANSFORM_LOOP_LIMIT = 500 |
no outgoing calls
no test coverage detected
searching dependent graphs…