cached-property icon indicating copy to clipboard operation
cached-property copied to clipboard

Can cached_property be a subclass of property?

Open aldanor opened this issue 10 years ago • 3 comments

There are certain pieces of code in some libraries, linters and static analyzers that check things like

if isinstance(attr, property):
    do_something()

This is especially important for use in metaclasses.

Obviously this fails with cached property; would it be possible to derive it from property so isinstance/issubclass checks work as expected?

aldanor avatar Oct 08 '15 10:10 aldanor

That's a fun idea! There isn't a stupid-quick fix for this: I quickly checked and if we inherit all the cached-property classes from Python's property built-in, then a third of the unit tests fail.

But I'm pretty certain there's a way to do it.

pydanny avatar Oct 08 '15 18:10 pydanny

since the python property is a data-property, that would mean always having a slow implementation the properties with annotations/ttl however look like a good candidate for that

RonnyPfannschmidt avatar Feb 15 '16 09:02 RonnyPfannschmidt

Inheriting from property also seems to fix #27

alimuldal avatar Jul 14 '16 20:07 alimuldal