osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Removing PendingDeprecationWarning


On Sun, Mar 24, 2019 at 8:57 PM Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> >
> > It was added "not be printed by default" version of DeprecationWarning.
> > But DeprecationWarning is not printed by default now.
>
> No, this was covered in PEP 565, and PendingDeprecationWarning was
> explicitly kept as a way of opting out of the revised semantics of
> DeprecationWarning.

I know PEP 565.  And I don't think difference between PendingDeprecationWarning
and DeprecationWarning is still too small to have two categories.  For example,

$ cat foo.py
import warnings
def foo():
    warnings.warn("foo", DeprecationWarning)

$ python3
Python 3.7.2 (default, Feb 12 2019, 08:15:36)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.foo()
>>>
(no warning shown)

$ cat >bar.py
import foo
foo.foo()

$ python3 bar.py
(no warning shown)


I can't find I'm using deprecated APIs even when I'm using REPL.
When people want to check use of deprecated APIs, they need to
use -X dev or -Wd option anyway.

We have many ways to deprecation:

* Document only deprecation (no warning) -- no actual removal is planned.
* FutureWarning -- to warn end users.
* DeprecationWarning -- to warn Python developers.
* PendingDeprecationWarning -- to warn Python developers.


-- 
Inada Naoki  <songofacandy at gmail.com>