(self, from_name: str | None, name: str | None)
| 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: |
| 93 | # import x.y.z<tab> |
| 94 | assert name is not None |
| 95 | path, prefix = self.get_path_and_prefix(name) |
| 96 | modules = self.find_modules(path, prefix) |
| 97 | return [self.format_completion(path, module) for module in modules], None |
| 98 | |
| 99 | if name is None: |
| 100 | # from x.y.z<tab> |
| 101 | path, prefix = self.get_path_and_prefix(from_name) |
| 102 | modules = self.find_modules(path, prefix) |
| 103 | return [self.format_completion(path, module) for module in modules], None |
| 104 | |
| 105 | # from x.y import z<tab> |
| 106 | submodules = self.find_modules(from_name, name) |
| 107 | attributes, action = self.find_attributes(from_name, name) |
| 108 | return sorted({*submodules, *attributes}), action |
| 109 | |
| 110 | def find_modules(self, path: str, prefix: str) -> list[str]: |
| 111 | """Find all modules under 'path' that start with 'prefix'.""" |
no test coverage detected