mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 16:41:21 +00:00
Avoid potential TypeErrors using LazyInitialise
This commit is contained in:
parent
a743b01bcf
commit
d5b0bb4d32
@ -13,7 +13,7 @@ class LazyInitialise:
|
|||||||
|
|
||||||
def __get__(self, instance, owner):
|
def __get__(self, instance, owner):
|
||||||
if instance is None:
|
if instance is None:
|
||||||
raise TypeError('Cannot get object property from class!')
|
return self # avoids potential __new__ TypeError
|
||||||
value = self.func(instance)
|
value = self.func(instance)
|
||||||
setattr(instance, self.func.__name__, value)
|
setattr(instance, self.func.__name__, value)
|
||||||
return value
|
return value
|
||||||
|
Loading…
Reference in New Issue
Block a user