diff --git a/python/src/com/jetbrains/python/psi/types/PyClassType.java b/python/src/com/jetbrains/python/psi/types/PyClassType.java index 00609ae38dca..77e270dc2b8b 100644 --- a/python/src/com/jetbrains/python/psi/types/PyClassType.java +++ b/python/src/com/jetbrains/python/psi/types/PyClassType.java @@ -175,6 +175,15 @@ public class PyClassType extends UserDataHolderBase implements PyType { } } } + if (isDefinition() && myClass.isNewStyleClass()) { + PyClassType typeType = PyBuiltinCache.getInstance(myClass).getObjectType("type"); + if (typeType != null) { + List typeMembers = typeType.resolveMember(name, location, direction, resolveContext); + if (typeMembers != null && !typeMembers.isEmpty()) { + return typeMembers; + } + } + } return Collections.emptyList(); } @@ -238,6 +247,13 @@ public class PyClassType extends UserDataHolderBase implements PyType { addInheritedMembers(prefix, location, context, ret); + if (isDefinition() && myClass.isNewStyleClass()) { + PyClassType typeType = PyBuiltinCache.getInstance(myClass).getObjectType("type"); + if (typeType != null) { + Collections.addAll(ret, typeType.getCompletionVariants(prefix, location, context)); + } + } + return ret.toArray(); } diff --git a/python/testData/completion/mro.after.py b/python/testData/completion/mro.after.py new file mode 100644 index 000000000000..f11910d9e13a --- /dev/null +++ b/python/testData/completion/mro.after.py @@ -0,0 +1,5 @@ +class C(object): + pass + + +C.__mro__ \ No newline at end of file diff --git a/python/testData/completion/mro.py b/python/testData/completion/mro.py new file mode 100644 index 000000000000..cee5359fcabe --- /dev/null +++ b/python/testData/completion/mro.py @@ -0,0 +1,5 @@ +class C(object): + pass + + +C.__m \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/mro.py b/python/testData/inspections/PyUnresolvedReferencesInspection/mro.py new file mode 100644 index 000000000000..ea1d5b821705 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/mro.py @@ -0,0 +1,3 @@ +class C(object): pass + +C.__mro__ diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java index 77fb149bddd4..cb38bda54490 100644 --- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java +++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java @@ -392,4 +392,8 @@ public class PythonCompletionTest extends PyLightFixtureTestCase { public void testDuplicateColon() { // PY-2652 doTest(); } + + public void testMro() { // PY-3989 + doTest(); + } } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java index 185631923cf1..49f972c3ab2e 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java @@ -36,6 +36,10 @@ public class PyUnresolvedReferencesInspectionTest extends PyLightFixtureTestCase doTest(); } + public void testMro() { // PY-3989 + doTest(); + } + public void testConditionalImports() { // PY-983 myFixture.configureByFiles(TEST_DIRECTORY + getTestName(true) + ".py", TEST_DIRECTORY + "lib1.py",