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

Function current_import

bpython/line.py:219–234  ·  view source on GitHub ↗
(cursor_offset: int, line: str)

Source from the content-addressed store, hash-verified

217
218
219def current_import(cursor_offset: int, line: str) -> LinePart | None:
220 # TODO allow for multiple as's
221 baseline = _current_import_re_1.search(line)
222 if baseline is None:
223 return None
224 match1 = _current_import_re_2.search(line[baseline.end() :])
225 if match1 is None:
226 return None
227 for m in chain(
228 (match1,), _current_import_re_3.finditer(line[baseline.end() :])
229 ):
230 start = baseline.end() + m.start(1)
231 end = baseline.end() + m.end(1)
232 if start < cursor_offset <= end:
233 return LinePart(start, end, m.group(1))
234 return None
235
236
237_current_method_definition_name_re = LazyReCompile(r"def\s+([a-zA-Z_][\w]*)")

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