From d2db938d50371e2598e39def3e7c663375e2c9bb Mon Sep 17 00:00:00 2001 From: Brandon Hancock Date: Fri, 1 Nov 2024 16:40:16 -0400 Subject: [PATCH] fix flows lint --- src/crewai/flow/flow.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/crewai/flow/flow.py b/src/crewai/flow/flow.py index 16f1cf9f0..9b6463d65 100644 --- a/src/crewai/flow/flow.py +++ b/src/crewai/flow/flow.py @@ -217,12 +217,20 @@ class Flow(Generic[T], metaclass=FlowMeta): if isinstance(self._state, BaseModel): # Structured state management try: - M = self._state.__class__ + # Define a function to create the dynamic class + def create_model_with_extra_forbid( + base_model: Type[BaseModel], + ) -> Type[BaseModel]: + class ModelWithExtraForbid(base_model): # type: ignore + model_config = base_model.model_config.copy() + model_config["extra"] = "forbid" - # Dynamically create a new model class with 'extra' set to 'forbid' - class ModelWithExtraForbid(M): - model_config = M.model_config.copy() - model_config["extra"] = "forbid" + return ModelWithExtraForbid + + # Create the dynamic class + ModelWithExtraForbid = create_model_with_extra_forbid( + self._state.__class__ + ) # Create a new instance using the combined state and inputs self._state = cast(