mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed resolving star imports for nested packages with __all__ (PY-13585)
This commit is contained in:
@@ -477,9 +477,13 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
if (starImportSource != null) {
|
||||
starImportSource = PyUtil.turnDirIntoInit(starImportSource);
|
||||
if (starImportSource instanceof PyFile) {
|
||||
final PsiElement result = ((PyFile)starImportSource).getElementNamed(name);
|
||||
final PyFile file = (PyFile)starImportSource;
|
||||
final PsiElement result = file.getElementNamed(name);
|
||||
if (result != null) {
|
||||
return result;
|
||||
final List<String> dunderAll = file.getDunderAll();
|
||||
if ((dunderAll == null && !name.startsWith("_")) || (dunderAll != null && dunderAll.contains(name))) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import b
|
||||
<warning descr="Unused import statement">from p1 import *</warning>
|
||||
print(b)
|
||||
+1
@@ -0,0 +1 @@
|
||||
from p1.m1 import *
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import b
|
||||
__all__ = []
|
||||
+5
@@ -376,6 +376,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-13585
|
||||
public void testUnusedImportBeforeStarDunderAll() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user