MCPcopy Index your code
hub / github.com/ipython/ipython / has_sunken_brackets

Function has_sunken_brackets

IPython/core/inputtransformer2.py:646–656  ·  view source on GitHub ↗

Check if the depth of brackets in the list of tokens drops below 0

(tokens: List[tokenize.TokenInfo])

Source from the content-addressed store, hash-verified

644
645
646def 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
659TRANSFORM_LOOP_LIMIT = 500

Callers 1

check_completeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…