From d41f54cbb35ce79cd3cdb5d14f3fd2f053ca2bba Mon Sep 17 00:00:00 2001 From: Serhii Lazebnyi Date: Thu, 5 Dec 2024 15:44:26 +0100 Subject: [PATCH] Changed helpers var name in _extract_data and typo in schema loader --- .../parsers/model_to_component_factory.py | 10 +++++----- .../declarative/schema/dynamic_schema_loader.py | 14 +++++++------- .../schema/test_dynamic_schema_loader.py | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py b/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py index f8f62eeb5..0c97ba914 100644 --- a/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +++ b/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py @@ -1585,12 +1585,12 @@ def create_types_map(model: TypesMapModel, **kwargs: Any) -> TypesMap: def create_schema_type_identifier( self, model: SchemaTypeIdentifierModel, config: Config, **kwargs: Any ) -> SchemaTypeIdentifier: - types_map = [] + types_mapping = [] if model.types_mapping: - types_map.extend( + types_mapping.extend( [ - self._create_component_from_model(types_pair, config=config) - for types_pair in model.types_mapping + self._create_component_from_model(types_map, config=config) + for types_map in model.types_mapping ] ) model_schema_pointer: List[Union[InterpolatedString, str]] = ( @@ -1605,7 +1605,7 @@ def create_schema_type_identifier( schema_pointer=model_schema_pointer, key_pointer=model_key_pointer, type_pointer=model_type_pointer, - types_map=types_map, + types_mapping=types_mapping, parameters=model.parameters or {}, ) diff --git a/airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py b/airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py index 4b6e9e864..d8aff3742 100644 --- a/airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py +++ b/airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py @@ -64,7 +64,7 @@ class SchemaTypeIdentifier: key_pointer: List[Union[InterpolatedString, str]] parameters: InitVar[Mapping[str, Any]] type_pointer: Optional[List[Union[InterpolatedString, str]]] = None - types_map: Optional[List[TypesMap]] = None + types_mapping: Optional[List[TypesMap]] = None schema_pointer: Optional[List[Union[InterpolatedString, str]]] = None def __post_init__(self, parameters: Mapping[str, Any]) -> None: @@ -182,10 +182,10 @@ def _replace_type_if_not_valid( """ Replaces a field type if it matches a type mapping in `types_map`. """ - if self.schema_type_identifier.types_map: - for types_pair in self.schema_type_identifier.types_map: - if field_type == types_pair.current_type: - return types_pair.target_type + if self.schema_type_identifier.types_mapping: + for types_map in self.schema_type_identifier.types_mapping: + if field_type == types_map.current_type: + return types_map.target_type return field_type @staticmethod @@ -212,8 +212,8 @@ def _extract_data( return body path = [ - path.eval(self.config) if not isinstance(path, str) else path - for path in extraction_path + node.eval(self.config) if not isinstance(node, str) else node + for node in extraction_path ] return dpath.get(body, path, default=default) # type: ignore # extracted will be a MutableMapping, given input data structure diff --git a/unit_tests/sources/declarative/schema/test_dynamic_schema_loader.py b/unit_tests/sources/declarative/schema/test_dynamic_schema_loader.py index da0770141..859077c70 100644 --- a/unit_tests/sources/declarative/schema/test_dynamic_schema_loader.py +++ b/unit_tests/sources/declarative/schema/test_dynamic_schema_loader.py @@ -30,7 +30,7 @@ def mock_schema_type_identifier(): schema_pointer=["schema"], key_pointer=["key"], type_pointer=["type"], - types_map=[], + types_mapping=[], parameters={}, )