Draft Idea For Pre Tasks To Be Context Aware #1041
Draft
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.
This commit introduces a draft implementation of a mechanism that allows tasks designated as pre-tasks to retain information about their assignment via a
_is_pre_of
attribute.When a
Call
object is created from aTask
instance with this attribute set, the resultingCall
will include a reference to the main task that declared the current task as a pre-task. This reference is made accessible during the pre-task's execution through the context passed to the task, allowing for greater introspection or conditional behavior based on the calling task.The approach taken here favors composability and minimal intrusion into existing class implementations. It uses idiomatic Python patterns—such as generic decorators and lightweight descriptors—to introduce this functionality without tightly coupling it to the core
Task
orCall
classes.It’s possible that making tasks more stateful in this way—by tracking their assignment as pre-tasks—may not align with the long-term design philosophy of this library. If that's the case, I completely understand, and I'm happy to explore other areas where I could contribute to this great project.
There are a few issues in the CI pipeline, if this idea gets some push, I will address them promptly
ToDo