sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
951 stars 405 forks source link

lifecycle: Make use of `@warnings.deprecated` decorator (py3.13+?) #2554

Open dgw opened 7 months ago

dgw commented 7 months ago

Issue title reflects just how long-term this might be… As of 2023-11-11, a new warnings.deprecated decorator is "Accepted" (via PEP 702) but not yet fully implemented in Python 3.13 alpha (see python/cpython#104004). The final release of Python 3.13.0 isn't expected until next October (2024), so this is definitely a planning issue for now. I just want to make sure it isn't forgotten.

We've had occasional conversations about improvements to Sopel's own @deprecated decorator—including a possible switch to use warnings instead of the normal logger—for a few years now. This upcoming stdlib feature can give us both a runtime warning and a type-checker warning, and it looks like our existing decorator should be able to simply wrap this:

@deprecated is available as an experimental decorator since typing-extensions 4.5.0, and will most likely be updated with a stdlib-compatible, non-experimental implementation by the time Python 3.13.0 is finalized, if not even before then. We'll be able to use that for our own backward compatibility purposes.