From c80c39e29ed1fefe63b829ec88de0a3dec4693b1 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 21 Mar 2018 20:36:27 +0300 Subject: [PATCH] Update PyClass so local slot overrides inherited property (PY-28206) --- .../jetbrains/python/psi/impl/PyClassImpl.java | 4 +++- .../PyPropertyAccessInspectionTest.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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() {