mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed useless 'import resolve to its containing file' for import statements in __init__.py (PY-14398)
This commit is contained in:
+1
-10
@@ -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) {
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
import p1.m1
|
||||
+5
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user