diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java index 8c704806c66b..2ada796cdf3b 100644 --- a/python/src/com/jetbrains/python/psi/PyUtil.java +++ b/python/src/com/jetbrains/python/psi/PyUtil.java @@ -628,6 +628,17 @@ public class PyUtil { return target; } + public static boolean isPackage(@NotNull PsiDirectory directory) { + if (turnDirIntoInit(directory) != null) { + return true; + } + return hasNamespacePackageFile(directory); + } + + public static boolean isPackage(@NotNull PsiFile file) { + return turnInitIntoDir(file) != null; + } + /** * Counts initial underscores of an identifier. * diff --git a/python/src/com/jetbrains/python/psi/types/PyModuleType.java b/python/src/com/jetbrains/python/psi/types/PyModuleType.java index 7a8db56f3209..ee4ad7814d7b 100644 --- a/python/src/com/jetbrains/python/psi/types/PyModuleType.java +++ b/python/src/com/jetbrains/python/psi/types/PyModuleType.java @@ -61,7 +61,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje if (attribute != null) { return ResolveResultList.to(attribute); } - if (location != null && isPackage(myModule)) { + if (location != null && PyUtil.isPackage(myModule)) { return resolveImplicitPackageMember(name, location); } return null; @@ -128,10 +128,6 @@ public class PyModuleType implements PyType { // Modules don't descend from obje return visibleImports; } - private static boolean isPackage(@NotNull PyFile file) { - return PyUtil.turnInitIntoDir(file) != null; - } - /** * @param directory the module directory *