mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
PY-46623 Add setter and deleter to cached_property
GitOrigin-RevId: 97c7703a89d0e1c49f829aed3474006ac7e5324a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
08254bb652
commit
3df8d77318
@@ -109,6 +109,7 @@ public final @NonNls class PyNames {
|
||||
public static final String SETTER = "setter";
|
||||
public static final String DELETER = "deleter";
|
||||
public static final String GETTER = "getter";
|
||||
public static final String CACHED_PROPERTY = "cached_property";
|
||||
|
||||
public static final String ALL = "__all__";
|
||||
public static final String SLOTS = "__slots__";
|
||||
|
||||
@@ -43,6 +43,7 @@ public final class PyKnownDecoratorUtil {
|
||||
FUNCTOOLS_WRAPS("functools.wraps"),
|
||||
FUNCTOOLS_TOTAL_ORDERING("functools.total_ordering"),
|
||||
FUNCTOOLS_SINGLEDISPATCH("functools.singledispatch"),
|
||||
FUNCTOOLS_CACHED_PROPERTY("functools.cached_property"),
|
||||
|
||||
ABC_ABSTRACTMETHOD("abc.abstractmethod"),
|
||||
ABC_ABSTRACTCLASSMETHOD("abc.abstractclassmethod"),
|
||||
@@ -121,6 +122,7 @@ public final class PyKnownDecoratorUtil {
|
||||
private static final Set<KnownDecorator> PROPERTY_DECORATORS = EnumSet.of(PROPERTY,
|
||||
ABC_ABSTRACTPROPERTY,
|
||||
PYRAMID_DECORATOR_REIFY,
|
||||
FUNCTOOLS_CACHED_PROPERTY,
|
||||
DJANGO_UTILS_FUNCTIONAL_CACHED_PROPERTY,
|
||||
KOMBU_UTILS_CACHED_PROPERTY);
|
||||
|
||||
|
||||
@@ -683,6 +683,12 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
decoName = knownName;
|
||||
}
|
||||
}
|
||||
if (PyNames.CACHED_PROPERTY.equals(decoName)) {
|
||||
getter = new Maybe<>(method);
|
||||
setter = new Maybe<>(method);
|
||||
deleter = new Maybe<>(method);
|
||||
break;
|
||||
}
|
||||
if (PyNames.PROPERTY.equals(decoName) ||
|
||||
PyKnownDecoratorUtil.isPropertyDecorator(deco, TypeEvalContext.codeInsightFallback(getProject())) ||
|
||||
qname.matches(decoratorName, PyNames.GETTER)) {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from foo import Foo
|
||||
f = Foo()
|
||||
del f.foo
|
||||
f.foo = ""
|
||||
@@ -0,0 +1,8 @@
|
||||
from functools import cached_property
|
||||
|
||||
class Foo:
|
||||
def __init__(self):
|
||||
pass
|
||||
@cached_property
|
||||
def foo(self):
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
from foo import Foo
|
||||
f = Foo()
|
||||
del f.foo
|
||||
f.foo = ""
|
||||
@@ -0,0 +1,8 @@
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
class Foo:
|
||||
def __init__(self):
|
||||
pass
|
||||
@cached_property
|
||||
def foo(self):
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
from foo import Foo
|
||||
f = Foo()
|
||||
del f.foo
|
||||
f.foo = ""
|
||||
@@ -0,0 +1,8 @@
|
||||
from kombu.utils import cached_property
|
||||
|
||||
class Foo:
|
||||
def __init__(self):
|
||||
pass
|
||||
@cached_property
|
||||
def foo(self):
|
||||
pass
|
||||
@@ -37,6 +37,18 @@ public class PyPropertyAccessInspectionTest extends PyInspectionTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public void testCachedProperty() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
public void testDjangoCachedProperty() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
public void testKombuCachedProperty() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user