Code Duplication    Length = 14-14 lines in 2 locations

openscap_report/dataclasses/dataclasses.py 2 locations

@@ 1115-1128 (lines=14) @@
1112
    return _astuple_inner(obj, tuple_factory)
1113
1114
1115
def _astuple_inner(obj, tuple_factory):
1116
    if _is_dataclass_instance(obj):
1117
        result = []
1118
        for f in fields(obj):
1119
            value = _astuple_inner(getattr(obj, f.name), tuple_factory)
1120
            result.append(value)
1121
        return tuple_factory(result)
1122
    elif isinstance(obj, (list, tuple)):
1123
        return type(obj)(_astuple_inner(v, tuple_factory) for v in obj)
1124
    elif isinstance(obj, dict):
1125
        return type(obj)(
1126
            (_astuple_inner(k, tuple_factory), _astuple_inner(v, tuple_factory))
1127
            for k, v in obj.items()
1128
        )
1129
    else:
1130
        return copy.deepcopy(obj)
1131
@@ 1073-1086 (lines=14) @@
1070
    return _asdict_inner(obj, dict_factory)
1071
1072
1073
def _asdict_inner(obj, dict_factory):
1074
    if _is_dataclass_instance(obj):
1075
        result = []
1076
        for f in fields(obj):
1077
            value = _asdict_inner(getattr(obj, f.name), dict_factory)
1078
            result.append((f.name, value))
1079
        return dict_factory(result)
1080
    elif isinstance(obj, (list, tuple)):
1081
        return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
1082
    elif isinstance(obj, dict):
1083
        return type(obj)(
1084
            (_asdict_inner(k, dict_factory), _asdict_inner(v, dict_factory))
1085
            for k, v in obj.items()
1086
        )
1087
    else:
1088
        return copy.deepcopy(obj)
1089