MCPcopy Create free account
hub / github.com/ipython/ipython / _find_assign_op

Function _find_assign_op

IPython/core/inputtransformer2.py:106–120  ·  view source on GitHub ↗

Get the index of the first assignment in the line ('=' not inside brackets) Note: We don't try to support multiple special assignment (a = b = %foo)

(token_line)

Source from the content-addressed store, hash-verified

104
105
106def _find_assign_op(token_line) -> Union[int, None]:
107 """Get the index of the first assignment in the line ('=' not inside brackets)
108
109 Note: We don't try to support multiple special assignment (a = b = %foo)
110 """
111 paren_level = 0
112 for i, ti in enumerate(token_line):
113 s = ti.string
114 if s == '=' and paren_level == 0:
115 return i
116 if s in {'(','[','{'}:
117 paren_level += 1
118 elif s in {')', ']', '}'}:
119 if paren_level > 0:
120 paren_level -= 1
121
122def find_end_of_continued_line(lines, start_line: int):
123 """Find the last line of a line explicitly extended using backslashes.

Callers 3

findMethod · 0.85
findMethod · 0.85

Calls

no outgoing calls

Tested by 1