python_dto_mappers.auto_mapper ============================== .. py:module:: python_dto_mappers.auto_mapper .. autoapi-nested-parse:: Auto-mapping engine for matching fields between models. Classes ------- .. autoapisummary:: python_dto_mappers.auto_mapper.AutoMapper Module Contents --------------- .. py:class:: AutoMapper(source_type: Type, target_type: Type, exclude: Optional[Set[str]] = None) Class-based auto-mapper for matching fields. Automatically maps fields with matching names between source and target Pydantic models. Custom transforms override auto-mapping. Example: >>> mapper = AutoMapper(UserORM, UserDTO, exclude={'internal_id'}) >>> dto = mapper.map(user_orm) .. py:method:: add_transform(field: str, func: Any) -> AutoMapper Register a custom transform for a field. Args: field: Field name to transform func: Callable(source) -> value Returns: Self for chaining .. py:method:: map(source: Any) -> Any Map source instance to target type. Args: source: Source model instance Returns: Target model instance with mapped fields .. py:property:: source_type :type: Type Source model type. .. py:property:: target_type :type: Type Target model type. .. py:property:: mapped_fields :type: Set[str] Set of fields being mapped.