AutoImportQuickFix (final PyElement node, PsiReference reference) { final String text = reference.getElement().getText(); final String refText = reference.getRangeInElement().substring(text); // text of the part we're working with // don't propose meaningless auto imports if no interpreter is configured final Module module = ModuleUtilCore.findModuleForPsiElement(node); if (module != null && PythonSdkUtil.findPythonSdk(module) == null) { return null; } // don't show auto-import fix if we're trying to reference a variable which is defined below in the same scope ScopeOwner scopeOwner = PsiTreeUtil.getParentOfType(node, ScopeOwner.class); if (scopeOwner != null && ControlFlowCache.getScope(scopeOwner).containsDeclaration(refText)) { return null; } return addCandidates(node, reference, refText); }