Dmitry Trofimov
2014-02-11 18:00:45 +01:00
parent ab01855148
commit a2301175e3
3 changed files with 40 additions and 1 deletions

View File

@@ -51,7 +51,6 @@ import com.intellij.util.IncorrectOperationException;
import com.intellij.util.PlatformIcons;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PyTokenTypes;
@@ -964,6 +963,17 @@ public class PyUtil {
while (value instanceof PyParenthesizedExpression) {
value = ((PyParenthesizedExpression)value).getContainedExpression();
}
if (value instanceof PyReferenceExpression) {
PyReferenceExpression refExpr = (PyReferenceExpression)value;
PsiElement deref = refExpr.getReference().resolve();
if (deref instanceof PyTargetExpression) {
PyTargetExpression te = (PyTargetExpression)deref;
PyExpression assignedValue = te.findAssignedValue();
if (assignedValue instanceof PySequenceExpression) {
value = assignedValue;
}
}
}
if (value instanceof PySequenceExpression) {
final PyExpression[] elements = ((PySequenceExpression)value).getElements();
List<String> result = new ArrayList<String>(elements.length);

View File

@@ -0,0 +1,25 @@
class A(object):
__slots__ = ['a', 'b']
def __init__(self):
self.a = None # <- all ok here
self.b = None # <- all ok here
class B(A):
__slots__ = A.__slots__
def __init__(self):
super(B, self).__init__()
self.<warning descr="'B' object has no attribute 'c'">c</warning> = 'bug'
EXTERNAL_SLOTS = ['a', 'b']
class C(A):
__slots__ = EXTERNAL_SLOTS
def __init__(self):
super(C, self).__init__()
self.<warning descr="'C' object has no attribute 'c'">c</warning> = 'bug'

View File

@@ -52,6 +52,10 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doTest();
}
public void testSlotsAsExternal() {
doTest();
}
public void testImportExceptImportError() {
doTest();
}