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)
| 166 | |
| 167 | |
| 168 | def 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( |