MCPcopy Index your code
hub / github.com/bpython/bpython / current_from_import_import

Function current_from_import_import

bpython/line.py:190–211  ·  view source on GitHub ↗

If in from import completion, the word after import being completed returns None if cursor not in or just after one of these words

(
    cursor_offset: int, line: str
)

Source from the content-addressed store, hash-verified

188
189
190def current_from_import_import(
191 cursor_offset: int, line: str
192) -> LinePart | None:
193 """If in from import completion, the word after import being completed
194
195 returns None if cursor not in or just after one of these words
196 """
197 baseline = _current_from_import_import_re_1.search(line)
198 if baseline is None:
199 return None
200 match1 = _current_from_import_import_re_2.search(line[baseline.end() :])
201 if match1 is None:
202 return None
203 for m in chain(
204 (match1,),
205 _current_from_import_import_re_3.finditer(line[baseline.end() :]),
206 ):
207 start = baseline.end() + m.start(1)
208 end = baseline.end() + m.end(1)
209 if start < cursor_offset <= end:
210 return LinePart(start, end, m.group(1))
211 return None
212
213
214_current_import_re_1 = LazyReCompile(r"import")

Callers 1

completeMethod · 0.85

Calls 4

LinePartClass · 0.85
searchMethod · 0.80
finditerMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected