pydanny/cached-property

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

pbk0 opened this issue · 0 comments

pbk0 commented

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