On 29Jul2021 15:58, Paul Moore wrote:
>On Thu, 29 Jul 2021 at 15:39, Leonardo Freua
> 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
@Deprecated is used in Java and I find it very easy to use. Remember
you can also use parameters in decorators.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
On Thu, 29 Jul 2021 at 16:00, Paul Moore wrote:
>
> On Thu, 29 Jul 2021 at 15:39, Leonardo Freua
> wrote:
> >
> > Would it be interesting to create a @deprecated decorator to avoid adding
> > warnings.warn("deprecation message", DeprecationWarning, stacklevel=2) in
> > methods body?
>
> I
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
> 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
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 --
On Fri, Jul 30, 2021 at 7:11 AM Leonardo Freua
wrote:
>
> >>> First line of the body vs line before the declaration doesn't feel
> >>> like it makes much difference to me.
>
> Usually, decorators or annotations are placed near the method signature, that
> is, at the beginning where any reading
Specially I'd like to be able to deprecate the `Callable[..., Iterable[T]]`
type of contextlib.contextmanager
See https://github.com/python/typeshed/pull/2773#issuecomment-458872741
On Thu, 29 Jul 2021, 22:00 Thomas Grainger, wrote:
> I'd like to be able to specificy @deprecate on only some
>>> First line of the body vs line before the declaration doesn't feel
>>> like it makes much difference to me.
Usually, decorators or annotations are placed near the method signature, that
is, at the beginning where any reading begins, because it's easier to see that
method is deprecated or
I'd like to be able to specificy @deprecate on only some @overloads
On Thu, 29 Jul 2021, 21:59 Paul Bryan, wrote:
> I'm +1 on deprecation decorator, with some way to represent it so that it
> can be determined at runtime (e.g. dunder).
>
>
> On Thu, 2021-07-29 at 20:52 +, Leonardo Freua
I'm +1 on deprecation decorator, with some way to represent it so that
it can be determined at runtime (e.g. dunder).
On Thu, 2021-07-29 at 20:52 +, Leonardo Freua wrote:
> This is a good example of how using a decorator to express
> depreciation is much better and less polluting the method,
This is a good example of how using a decorator to express depreciation is much
better and less polluting the method, as the depreciation message doesn't need
to be in the method body.
In my view, it would be interesting for Python to natively have the ability to
annotate deprecated methods.
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
> 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?
The advantage of having a declarative API for deprecations is tooling
support. It is much easier to detect decorator application than to reliably
On Thu, 29 Jul 2021 at 15:39, Leonardo Freua
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.
> Using the decorator approach to
Hi,
I've been using https://pypi.org/project/Deprecated/ for quite some time
and I recommend it.
S.
On Thu, Jul 29, 2021 at 4:39 PM Leonardo Freua <
leonardo.batista.fr...@gmail.com> wrote:
> [Migrating from https://bugs.python.org/issue44701]
>
> Would it be interesting to create a
16 matches
Mail list logo