PoC: Bot instance inside method shortcuts using pydantic Validation Context #1210
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.
Description
Proof of concept for a replacement of ContextVar's for Bot instance inside method shortcuts
with a implementation based on a new pydantic feature named Validation Context.
Motivation
The motivation behind this pull request is to enhance the current implementation of ContextVar's for the Bot instance inside method shortcuts. The existing approach using ContextVar's can be confusing for new users and lacks clarity in its usage. By leveraging a new feature called "Validation Context" in Pydantic, we can provide a more transparent and intuitive solution.
The Validation Context feature in Pydantic offers a clearer and more explicit way of passing the Bot instance to method shortcuts. It eliminates the ambiguity associated with ContextVar's and provides a straightforward mechanism for accessing and utilizing the Bot instance within the methods. Additionally, this new approach opens up possibilities for using the Validation Context for other purposes as well, enhancing its versatility and making it a valuable addition to the codebase.
Overall, by adopting the Validation Context-based implementation, we can improve the readability, understandability, and maintainability of the codebase while also providing a more intuitive way of handling the Bot instance within method shortcuts.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Currently there are no tests for this feature.
I have tested this feature manually by running the example bot and checking if the bot instance is
correctly passed to the method shortcuts.
This feature should be discussed with the community before any tests are written.
Checklist: