diff --git a/python/src/com/jetbrains/python/validation/PythonReferenceImporter.java b/python/src/com/jetbrains/python/validation/PythonReferenceImporter.java index ab40da149ef9..428141953dbd 100644 --- a/python/src/com/jetbrains/python/validation/PythonReferenceImporter.java +++ b/python/src/com/jetbrains/python/validation/PythonReferenceImporter.java @@ -110,7 +110,7 @@ public class PythonReferenceImporter implements ReferenceImporter { for (PsiElement symbol : symbols) { if (isTopLevel(symbol)) { // we only want top-level symbols PsiFile srcfile = symbol.getContainingFile(); - if (srcfile != null && srcfile != existing_import_file) { + if (srcfile != null && srcfile != existing_import_file && srcfile != node.getContainingFile()) { VirtualFile vfile = srcfile.getVirtualFile(); if (vfile != null) { String import_path = ResolveImportUtil.findShortestImportableName(node, vfile);