Fixed resolving star imports for nested packages with __all__ (PY-13585)

This commit is contained in:
Andrey Vlasovskikh
2014-08-02 01:25:53 +04:00
parent 01b5b37d4d
commit 37f6807f02
6 changed files with 17 additions and 2 deletions
@@ -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;
}
}
}
}
@@ -0,0 +1,3 @@
import b
<warning descr="Unused import statement">from p1 import *</warning>
print(b)
@@ -376,6 +376,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doMultiFileTest();
}
// PY-13585
public void testUnusedImportBeforeStarDunderAll() {
doMultiFileTest();
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {