From: Henryk Plötz Date: Sat, 15 Sep 2018 23:20:26 +0000 (+0200) Subject: Clean unused code X-Git-Tag: v2.0.0~1^2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=845045c490af824d02039b562f2fa186d640587c;p=thirdparty%2Fpython-fints.git Clean unused code --- diff --git a/fints/fields.py b/fints/fields.py index 4bf3c00..7519c91 100644 --- a/fints/fields.py +++ b/fints/fields.py @@ -20,15 +20,6 @@ class ContainerField(TypedField): def _default_value(self): return self.type() - - @property - def flat_length(self): - result = 0 - for name, field in self.type._fields.items(): - if field.count is None: - raise TypeError("Cannot compute flat length of field {}.{} with variable count".format(self.__class__.__name__, name)) - result = result + field.count * field.flat_length - return result class DataElementGroupField(DocTypeMixin, ContainerField): diff --git a/fints/types.py b/fints/types.py index a49fb5b..dca8d8a 100644 --- a/fints/types.py +++ b/fints/types.py @@ -87,8 +87,6 @@ class Field: return "" class TypedField(Field, SubclassesMixin): - flat_length = 1 - def __new__(cls, *args, **kwargs): target_cls = None fallback_cls = None diff --git a/tests/test_formals.py b/tests/test_formals.py index 6292b54..14b72a7 100644 --- a/tests/test_formals.py +++ b/tests/test_formals.py @@ -218,36 +218,6 @@ def test_container_naive_parse(): assert i1.a == 23 assert i1.b == '42' -def test_field_flat_length(): - class A(Container): - a = NumericField() - - class B(Container): - b1 = DataElementGroupField(type=A) - b2 = DataElementGroupField(type=A, count=3) - b3 = DataElementGroupField(type=A, min_count=2) - - assert A._fields['a'].flat_length == 1 - assert B._fields['b1'].flat_length == 1 - assert B._fields['b2'].flat_length == 1 - - class C(Container): - c1 = DataElementGroupField(type=A) - c2 = DataElementGroupField(type=A, count=2) - c3 = DataElementGroupField(type=A, count=3) - - class D(Container): - d1 = DataElementGroupField(type=C, count=4) - - class E(Container): - e1 = DataElementGroupField(type=D) - e2 = DataElementGroupField(type=B) - - assert E._fields['e1'].flat_length == 4*(1+2+3) - - with pytest.raises(TypeError): - E._fields['e2'].flat_length - def test_invalid_spec(): with pytest.raises(ValueError): class A(Container):