diff --git a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java index f3efb36b62b5..b06f3997a29c 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java @@ -793,7 +793,9 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla return property; } - if (findMethodByName(name, false, null) != null || findClassAttribute(name, false, null) != null) { + if (findMethodByName(name, false, null) != null || + findClassAttribute(name, false, null) != null || + ContainerUtil.notNullize(getOwnSlots()).contains(name)) { return null; } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java index 565a7beff903..d765a9bf3faf 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java @@ -36,6 +36,22 @@ public class PyPropertyAccessInspectionTest extends PyInspectionTestCase { doTest(); } + // PY-28206 + public void testSlotOverridesProperty() { + doTestByText( + "class A(object):\n" + + " @property\n" + + " def name(self):\n" + + " return 'a'\n" + + "\n" + + "class B(A):\n" + + " __slots__ = ('name',)\n" + + "\n" + + " def __init__(self, name):\n" + + " self.name = name" + ); + } + @NotNull @Override protected Class getInspectionClass() {