From d042e66ef980b83ddd83a676be545e4037db31c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Kuchenbecker?= Date: Tue, 14 May 2024 13:41:45 +0000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Christoph Zwerschke --- .../delete_properties/model_transform.py | 2 +- .../infer_relations/data_transform.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/metldata/builtin_transformations/delete_properties/model_transform.py b/src/metldata/builtin_transformations/delete_properties/model_transform.py index 3a01945..0bfe657 100644 --- a/src/metldata/builtin_transformations/delete_properties/model_transform.py +++ b/src/metldata/builtin_transformations/delete_properties/model_transform.py @@ -64,5 +64,5 @@ def delete_properties( ) model_dict = model.model_dump() - model_dict.update({"classes": {**model.classes, **updated_class_defs}}) + model_dict["classes"].update(updated_class_defs) return SchemaPack.model_validate(model_dict) diff --git a/src/metldata/builtin_transformations/infer_relations/data_transform.py b/src/metldata/builtin_transformations/infer_relations/data_transform.py index f75fd8f..f941d24 100644 --- a/src/metldata/builtin_transformations/infer_relations/data_transform.py +++ b/src/metldata/builtin_transformations/infer_relations/data_transform.py @@ -44,8 +44,6 @@ as defined in the inferred relation """ -from collections.abc import Set - from schemapack.spec.custom_types import ResourceId from schemapack.spec.datapack import DataPack, Resource @@ -96,15 +94,12 @@ def resolve_active_path_element( if not source_resource: raise EvitableTransformationError() - target_resource_ids = source_resource.relations.get(path_element.property, set()) + target_resource_ids = source_resource.relations.get(path_element.property) if target_resource_ids is None: target_resource_ids = set() - - return ( - set(target_resource_ids) - if isinstance(target_resource_ids, Set) - else set([target_resource_ids]) - ) + elif isinstance(target_resource_ids, str): + target_resource_ids = {target_resource_ids} + return target_resource_ids def resolve_passive_path_element(