Return the next possible import completions for 'line'. For attributes completion, if the module to complete from is not imported, also return an action (prompt + callback to run if the user press TAB again) to import the module.
(self, line: str)
| 72 | self._stdlib_path = os.path.dirname(importlib.__path__[0]) |
| 73 | |
| 74 | def get_completions(self, line: str) -> tuple[list[str], CompletionAction | None] | None: |
| 75 | """Return the next possible import completions for 'line'. |
| 76 | |
| 77 | For attributes completion, if the module to complete from is not |
| 78 | imported, also return an action (prompt + callback to run if the |
| 79 | user press TAB again) to import the module. |
| 80 | """ |
| 81 | result = ImportParser(line).parse() |
| 82 | if not result: |
| 83 | return None |
| 84 | try: |
| 85 | return self.complete(*result) |
| 86 | except Exception: |
| 87 | # Some unexpected error occurred, make it look like |
| 88 | # no completions are available |
| 89 | return [], None |
| 90 | |
| 91 | def complete(self, from_name: str | None, name: str | None) -> tuple[list[str], CompletionAction | None]: |
| 92 | if from_name is None: |