Iterable<LocalQuickFix> (PyElement node, PsiReference reference, PsiElement element) { // look in other imported modules for this whole name if (!PythonImportUtils.isImportable(element)) { return Collections.emptyList(); } final PsiFile file = InjectedLanguageManager.getInstance(node.getProject()).getTopLevelFile(node); if (!(file instanceof PyFile)) { return Collections.emptyList(); } List<LocalQuickFix> result = new ArrayList<>(); AutoImportQuickFix importFix = PythonImportUtils.proposeImportFix(node, reference); if (importFix != null) { if (!suppressHintForAutoImport(node, importFix) && PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP) { final AutoImportHintAction autoImportHintAction = new AutoImportHintAction(importFix); result.add(autoImportHintAction); } else { result.add(importFix); } if (ScopeUtil.getScopeOwner(node) instanceof PyFunction) { result.add(importFix.forLocalImport()); } } else { String referencedName = node instanceof PyReferenceExpression refExpr && !refExpr.isQualified() ? refExpr.getReferencedName() : null; if (referencedName != null && PythonSdkUtil.findPythonSdk(node) != null) { if (PyPIPackageUtil.INSTANCE.isInPyPI(referencedName)) { result.add(new PyPackageRequirementsInspection.InstallAndImportPackageQuickFix(referencedName, null)); } else { String realPackageName = PyPackageAliasesProvider.commonImportAliases.get(referencedName); if (realPackageName != null && PyPIPackageUtil.INSTANCE.isInPyPI(realPackageName)) { result.add(new PyPackageRequirementsInspection.InstallAndImportPackageQuickFix(realPackageName, referencedName)); } } } } return result; }