Skip to content

Commit f3c9ff3

Browse files
author
Daniel Hiepler
committed
wrap __format__ method of _value and enforce Decimal() type in __init__
1 parent a3f74db commit f3c9ff3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drafthorse/models/elements.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,16 @@ def from_etree(self, root, strict=True):
158158
class DecimalElement(StringElement):
159159
def __init__(self, namespace, tag, value=None):
160160
super().__init__(namespace, tag)
161-
self._value = value
161+
self._value = Decimal(value) if value is not None else None
162162

163163
def to_etree(self):
164164
node = self._etree_node()
165165
node.text = str(self._value) if self._value is not None else ""
166166
return node
167167

168+
def __format__(self, fmt):
169+
return self._value.__format__(fmt)
170+
168171
def __str__(self):
169172
return str(self._value)
170173

0 commit comments

Comments
 (0)