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

Function current_from_import_from

bpython/line.py:168–180  ·  view source on GitHub ↗

If in from import completion, the word after from returns None if cursor not in or just after one of the two interesting parts of an import: from (module) import (name1, name2)

(cursor_offset: int, line: str)

Source from the content-addressed store, hash-verified

166
167
168def current_from_import_from(cursor_offset: int, line: str) -> LinePart | None:
169 """If in from import completion, the word after from
170
171 returns None if cursor not in or just after one of the two interesting
172 parts of an import: from (module) import (name1, name2)
173 """
174 # TODO allow for as's
175 for m in _current_from_import_from_re.finditer(line):
176 if (m.start(1) < cursor_offset <= m.end(1)) or (
177 m.start(2) < cursor_offset <= m.end(2)
178 ):
179 return LinePart(m.start(1), m.end(1), m.group(1))
180 return None
181
182
183_current_from_import_import_re_1 = LazyReCompile(

Callers 1

completeMethod · 0.85

Calls 3

LinePartClass · 0.85
finditerMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected