mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Forget to filter metaclass attributes by name while resolving class type member. This bug was introduced in PY-19702-related changes.
This commit is contained in:
@@ -48,6 +48,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -310,8 +311,11 @@ public class PyClassTypeImpl extends UserDataHolderBase implements PyClassType {
|
||||
final List<PyTargetExpression> typeInstanceAttributes = ((PyClassType)typeType).getPyClass().getInstanceAttributes();
|
||||
|
||||
if (!ContainerUtil.isEmpty(typeInstanceAttributes)) {
|
||||
return ContainerUtil
|
||||
.map(typeInstanceAttributes, member -> new RatedResolveResult(PyReferenceImpl.getRate(member, context), member));
|
||||
return typeInstanceAttributes
|
||||
.stream()
|
||||
.filter(member -> name.equals(member.getName()))
|
||||
.map(member -> new RatedResolveResult(PyReferenceImpl.getRate(member, context), member))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Meta(type):
|
||||
def __new__(cls, name, bases, attrs):
|
||||
foo = "abc"
|
||||
|
||||
|
||||
class A(metaclass=Meta):
|
||||
pass
|
||||
|
||||
|
||||
print(A().<warning descr="Unresolved attribute reference 'bar' for class 'A'">bar</warning>)
|
||||
+5
@@ -100,6 +100,11 @@ public class Py3UnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-19702
|
||||
public void testNonexistentMetaclassAttribute() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMetaclassStub() {
|
||||
doMultiFileTest("a.py");
|
||||
final Project project = myFixture.getProject();
|
||||
|
||||
Reference in New Issue
Block a user