On 29Jul2021 15:58, Paul Moore <[email protected]> wrote:
>On Thu, 29 Jul 2021 at 15:39, Leonardo Freua
><[email protected]> wrote:
>> Would it be interesting to create a @deprecated decorator to avoid
>> adding warnings.warn("deprecation message", DeprecationWarning,
>> stacklevel=2) in methods body?
>
>I don't see the value personally.
I do. Like various others here I wrote myself such a decorator long ago.
It was named @OBSOLETE and was by no means as complete as, say, the
Deprecated PyPI module. But the use case was the same:
@OBSOLETE
def old_func():
A decorator is concise and right up front in the code. As others have
mentioned, it becomes easy for tooling to see or use. (Not mine, it is a
miracle of crudity, just issuing warning() calls when the function is
first called from some place - it does at least say where the call was
made from.)
[...]
>Why would it be "interesting"? I don't see any practical advantage,
>and as soon as you need any form of logic you have to rewrite, so why
>bother?
That's the case for any presupplied convenience. But it covers off a lot
of the common cases to my mind.
The idea's a definite +1 from me.
Cheers,
Cameron Simpson <[email protected]>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/YG2VHW6RJNHGD6ITJNAQNWHS6LAR7GWR/
Code of Conduct: http://python.org/psf/codeofconduct/