@@ -677,7 +677,7 @@ def __init__(
677677
678678 def _init_mappings (self ) -> None :
679679 self .PYDANTIC_MODEL_TO_CONSTRUCTOR : Dict [
680- Type [BaseModel ], Union [Type [ComponentConstructor ], Callable [..., Any ]]
680+ Type [BaseModel ], Union [Type [ComponentConstructor [ Any ] ], Callable [..., Any ]]
681681 ] = {
682682 AddedFieldDefinitionModel : self .create_added_field_definition ,
683683 AddFieldsModel : self .create_add_fields ,
@@ -826,8 +826,11 @@ def create_component(
826826 )
827827
828828 def _create_component_from_model (
829- self , model : BaseModel , config : Config , ** kwargs : Any
830- ) -> ComponentConstructor [BaseModel ]:
829+ self ,
830+ model : BaseModel ,
831+ config : Config ,
832+ ** kwargs : Any ,
833+ ) -> Any : # TODO: change -> Any to -> ComponentConstructor[BaseModel] once all components are updated with ComponentConstructor logic
831834 if model .__class__ not in self .PYDANTIC_MODEL_TO_CONSTRUCTOR :
832835 raise ValueError (
833836 f"{ model .__class__ } with attributes { model } is not a valid component type"
@@ -847,8 +850,12 @@ def _create_component_from_model(
847850 ** kwargs ,
848851 )
849852 return component_instance
850- else :
853+ if inspect . ismethod ( component ) :
851854 return component (model = model , config = config , ** kwargs )
855+ raise ValueError (
856+ f"Unexpected component mapping type for { model .__class__ } . "
857+ f"Instance shource be one of ComponentConstructor or method implemented in ModelToComponentFactory"
858+ )
852859
853860 def get_model_deprecations (self ) -> List [ConnectorBuilderLogMessage ]:
854861 """
0 commit comments