-
-
Notifications
You must be signed in to change notification settings - Fork 408
Description
Requested Feature
This is a long term plan: the end goal is to remove SopelWrapper by using contextvars in the Sopel class itself. The main issue is that removing the SopelWrapper may break the following cases:
- using
isinstancewill break - type annotations using
SopelWrapperwill obviously fail, andmypywill complain - tests may need some adaptation to deal with a context specific bot instance
All these are perfectly acceptable for a major release, but shouldn't be introduced in a minor release. We should also ensure a period of deprecation, with warning in the documentation, and if possible in the code itself.
After a conversation on IRC, a rough plan is:
- Sopel 8.0: warn in the documentation/release note/somewhere else that we are deprecating
SopelWrapper
bot: add deprecation notice to SopelWrapper #2521 (target version for removal unspecified for now, but probably 9.0) - Sopel 8.1: Implement
SopelWrapperbehavior withcontextvars#2526 - Sopel 8.1: Replace
SopelWrapperbySopelin the code, and add code deprecation warning to prevent its future usage #2639 - Sopel 9.0: Remove
SopelWrapperin favor ofcontextvarsimplementation #2527
Problems Solved
Today, we use SopelWrapper to wrap an instance of Sopel and use it in plugin callable (the bot argument), and as a result:
- we have an extra class to take care of
- the documentation is split between 3 classes (the irc abstract class,
Sopel, andSopelWrapper) - it uses magic method and magic behavior of Python related to attribute management, and we don't really need that
- whenever we add/remove a fonction on
Sopelwe have to consider how it will or can be used withSopelWrapper, requiring more code, more tests, maybe more documentation, etc. - function signature need to know if they want a
SopelWrapperobject, aSopelobject, or both, which can be confusing
Notes
PR #2443 started the conversation around contextvars and removing SopelWrapper, but making such a drastic change in Sopel 8 is too much, hence this issue with a proper plan with a target version as Sopel 9.0.