Skip to content

Commit 4937710

Browse files
committed
Handle model attributes such as list and dict
1 parent 928870b commit 4937710

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ltk/widgets.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def set_value(self, value):
643643
""" Set the value of the attribute """
644644
try:
645645
typed_value = type(self.value)(value)
646-
except:
646+
except Exception: # pylint: disable=broad-except
647647
typed_value = value
648648
if typed_value == self.value:
649649
return
@@ -653,6 +653,13 @@ def set_value(self, value):
653653
listener(self)
654654
return self.value
655655

656+
def __getattr__(self, name):
657+
# handle calls to list.push or similar apis on the attribute.
658+
try:
659+
return getattr(self.value, name)
660+
except Exception as e:
661+
raise AttributeError(f"Model attribute {self.__class__.__name__} does not have attribute {name}") from e
662+
656663
def __int__(self): return int(self.value) # pylint: disable=multiple-statements
657664
def __bool__(self): return bool(self.value) # pylint: disable=multiple-statements
658665
def __float__(self): return float(self.value) # pylint: disable=multiple-statements

0 commit comments

Comments
 (0)