Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can cached_property be a subclass of property? #26

Open
aldanor opened this issue Oct 8, 2015 · 3 comments
Open

Can cached_property be a subclass of property? #26

aldanor opened this issue Oct 8, 2015 · 3 comments

Comments

@aldanor
Copy link

aldanor commented Oct 8, 2015

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?

@pydanny pydanny self-assigned this Oct 8, 2015
@pydanny
Copy link
Owner

pydanny commented Oct 8, 2015

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.

@RonnyPfannschmidt
Copy link

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

@alimuldal
Copy link

Inheriting from property also seems to fix #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants