Completed
Pull Request — master (#19)
by Ionel Cristian
01:00
created

src.hunter.cached_property   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 10
Duplicated Lines 0 %
Metric Value
dl 0
loc 10
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __get__() 0 5 2
A __init__() 0 3 1
1
class cached_property(object):
2
    def __init__(self, func):
3
        self.func = func
4
        self.__doc__ = func.__doc__
5
6
    def __get__(self, obj, cls):
7
        if obj is None:
8
            return self
9
        value = obj.__dict__[self.func.__name__] = self.func(obj)
10
        return value
11