Setter is called twice for default values
smarie opened this issue · 0 comments
smarie commented
When an argument is declared as optional with default value in the constructor, everytime it is set by @autoargs
the setter is called twice (once with the default value and once with the value provided by the user)
global counter
counter = 0
class Home(object):
@autoargs
def __init__(self, foo, bar=False):
pass
@property
def bar(self):
return self._bar
@bar.setter
def bar(self, value):
global counter
counter += 1
self._bar = value
Home(None, bar=True)
assert counter == 1 # AssertionError : counter is 2 !