mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 10:51:32 +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):
|
||||
if instance is None:
|
||||
raise TypeError('Cannot get object property from class!')
|
||||
return self # avoids potential __new__ TypeError
|
||||
value = self.func(instance)
|
||||
setattr(instance, self.func.__name__, value)
|
||||
return value
|
||||
|
Loading…
Reference in New Issue
Block a user