diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/stubs/PyQualifiedNameCompletionMatcher.java b/python/python-psi-impl/src/com/jetbrains/python/psi/stubs/PyQualifiedNameCompletionMatcher.java index 3c3a262b1594..f01a764c3e63 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/stubs/PyQualifiedNameCompletionMatcher.java +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/stubs/PyQualifiedNameCompletionMatcher.java @@ -212,7 +212,8 @@ public class PyQualifiedNameCompletionMatcher { VirtualFile closestRoot = findClosestRoot(nameAnchor, projectFileIndex); if (closestRoot == null) return null; String relativePath = VfsUtilCore.getRelativePath(nameAnchor, closestRoot); - if (relativePath == null) return null; + // A relative path can be empty in case of __init__.py directly inside a root. + if (relativePath == null || relativePath.isEmpty()) return null; return convertPathToImportableQualifiedName(relativePath); }