Fix issue #2392: Preserve ConditionalTask type in Crew.copy() and kickoff_for_each() #2393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2392
Issue
When
Crew.kickoff_for_each()is called for a crew that contains ConditionalTask items, the copied crews cast the ConditionalTask as a Task instead. As a result, conditional task crews are broken when running withkickoff_for_each().Fix
Modified the Task.copy() method to preserve the original task type by using
self.__class__instead of hardcodingTaskwhen creating the copied task.Testing
Added tests to verify that ConditionalTask objects are properly preserved when copying a Crew and when using kickoff_for_each().
Link to Devin run: https://app.devin.ai/sessions/9ac94a2c1dde42eea90718f4074e9222