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

is:issue is:open propagate cached property behavior to child class with abstract method #153

Open
pbk0 opened this issue May 2, 2019 · 0 comments

Comments

@pbk0
Copy link

pbk0 commented May 2, 2019

This is a feature request

Code:

import numpy as np
import abc
from cached_property import cached_property


class A(abc.ABC):

    @abc.abstractmethod
    @cached_property
    def v1(self):
        ...


class B:

    @cached_property  # things dont work if we dont add this
    def v1(self):
        return np.random.randint(133)


np.random.seed(123)
a = B()
print(a.v1)
print(a.v1)
print(a.v1)

Output:

109
109
109

Can we have this code run where there is no need to have @cached_property decorator for child class B. Or do you think this is not useful to implement as it violates some coding principles as the property v1() will now appear as a method in child class B to all IDEs

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

No branches or pull requests

1 participant