Skip to content

Commit b8610c8

Browse files
henrykraphaelm
authored andcommitted
ValueList cannot actually contain another ValueList
1 parent 6599f46 commit b8610c8

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

fints/formals.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ def __len__(self):
5656
if isinstance(val, Container):
5757
if val.is_unset():
5858
continue
59-
elif isinstance(val, ValueList):
60-
if len(val) == 0:
61-
continue
6259
elif val is None:
6360
continue
6461
retval = i+1
@@ -161,7 +158,7 @@ def _check_value_length(self, value):
161158
def render(self, value):
162159
if value is None:
163160
return ""
164-
161+
165162
return self._render_value(value)
166163

167164
class TypedField(Field, SubclassesMixin):

tests/test_formals.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,23 @@ def test_sequence_repr():
298298

299299
assert repr(s) == 'SegmentSequence([])'
300300

301+
def test_valuelist_repr():
302+
class A(Container):
303+
a = NumericField(max_count=3)
304+
305+
i1 = A()
306+
assert repr(i1.a) == "[]"
307+
308+
def test_empty_list():
309+
class A(Container):
310+
a = NumericField(max_count=3)
311+
312+
i1 = A()
313+
assert len(i1.a) == 0
314+
315+
i2 = A(a=[None])
316+
assert len(i2.a) == 0
317+
301318
def test_segmentheader_short():
302319
h = SegmentHeader('HNHBS', 5, 1)
303320

0 commit comments

Comments
 (0)