mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't resolve attributes of metaclasses on instances of their instances
This commit is contained in:
@@ -196,6 +196,9 @@ public class PyClassTypeImpl extends UserDataHolderBase implements PyClassType {
|
||||
if (inherited) {
|
||||
for (PyClassLikeType type : myClass.getAncestorTypes(context)) {
|
||||
if (type instanceof PyClassType) {
|
||||
if (!myIsDefinition) {
|
||||
type = type.toInstance();
|
||||
}
|
||||
PsiElement superMember = resolveClassMember(((PyClassType)type).getPyClass(), myIsDefinition, name, null);
|
||||
if (superMember != null) {
|
||||
return ResolveResultList.to(superMember);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class GenericMeta(type):
|
||||
def __getitem__(self, args):
|
||||
pass
|
||||
|
||||
|
||||
class Generic(object):
|
||||
__metaclass__ = GenericMeta
|
||||
|
||||
|
||||
class C(Generic['foo']):
|
||||
pass
|
||||
|
||||
|
||||
print(C['bar'])
|
||||
c = C()
|
||||
print(c<warning descr="Class 'C' does not define '__getitem__', so the '[]' operator cannot be used on its instances">[</warning>'baz'])
|
||||
+4
@@ -431,6 +431,10 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
|
||||
assertTrue(JDOMUtil.writeElement(serialized).contains("foo.Bar.*"));
|
||||
}
|
||||
|
||||
public void testMetaClassMembers() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user