
Recently I needed to do just that on an API and went with the decorator approach. Having this on the stdlib would be nice, and we can make it more powerful than just raising a warning. For instance, we could attach a `deprecated = True` to the function object so that framework authors can use that to handle depreciation as well - think flask endpoints. Another option is to have an `alternative` optional kwarg in the decorator, something like def new_function(): .... @deprecated(alternative=new_function) def old_function(): ... This would raise a warning stating that `new_function` should be used in the place of `old_function` [image: --] *Felipe* Bidu *(Felipe Rodrigues)* [image: https://]*https://felipevr.com* <https://felipevr.com> On Fri, Jul 30, 2021 at 9:22 AM Jack DeVries <jdevries3133@gmail.com> wrote:
Perhaps another approach would be to make a more general purpose warning decorator, that would give a warning when invoking a function or instantiating a class. It could be used for deprecation notices, of course, but has the potential for tooling to give other types of warnings, such as using a thread unsafe call in a threading context.
What about "mark"
import mark
@mark.deprecated @mark.slow @mark.thread_unsafe @mark.insecure
On Thu, Jul 29, 2021, 5:26 PM Leonardo Freua < leonardo.batista.freua@gmail.com> wrote:
Hi Sergei, I really thought your proposal was very good, in fact, it's quite complete with examples in libraries that I didn't even know implement a depreciation API.
Thanks for the contribution. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TGQVDH... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7WCBL5... Code of Conduct: http://python.org/psf/codeofconduct/