| 271 | return self._global_cache |
| 272 | |
| 273 | def _maybe_import_module(self, fqname: str) -> ModuleType | None: |
| 274 | if any(pattern.fullmatch(fqname) for pattern in AUTO_IMPORT_DENYLIST): |
| 275 | # Special-cased modules with known import side-effects |
| 276 | return None |
| 277 | root = fqname.split(".")[0] |
| 278 | mod_info = next((m for m in self.global_cache if m.name == root), None) |
| 279 | if not mod_info or not self._is_stdlib_module(mod_info): |
| 280 | # Only import stdlib modules (no risk of import side-effects) |
| 281 | return None |
| 282 | try: |
| 283 | return importlib.import_module(fqname) |
| 284 | except Exception: |
| 285 | sys.modules.pop(fqname, None) # Clean half-imported module |
| 286 | return None |
| 287 | |
| 288 | def _get_import_completion_action(self, path: str) -> CompletionAction: |
| 289 | prompt = ("[ module not imported, press again to import it " |