Fixed useless 'import resolve to its containing file' for import statements in __init__.py (PY-14398)

This commit is contained in:
Andrey Vlasovskikh
2014-11-20 16:04:56 +03:00
parent 282d978090
commit b34448484f
4 changed files with 7 additions and 10 deletions
@@ -383,16 +383,7 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
}
private static boolean isContainingFileImportAllowed(PyElement node, PsiFile target) {
// import resolving to containing file is allowed when we're importing from the current package and the containing file
// is __init__.py (PY-5265)
final boolean insideFromImport = PsiTreeUtil.getParentOfType(node, PyFromImportStatement.class) != null;
if (!insideFromImport) {
return false;
}
if (PyImportStatementNavigator.getImportStatementByElement(node) != null) {
return false;
}
return target.getName().equals(PyNames.INIT_DOT_PY);
return PyImportStatementNavigator.getImportStatementByElement(node) == null && target.getName().equals(PyNames.INIT_DOT_PY);
}
private void processReferenceInImportGuard(PyElement node, PyExceptPart guard) {
@@ -435,6 +435,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doTest();
}
// PY-14398
public void testImportToContainingFileInPackage() {
doMultiFileTest("p1/__init__.py");
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {