Issue #16345 has been updated by akr (Akira Tanaka).


duerst (Martin D=FCrst) wrote:
> akr (Akira Tanaka) wrote:
> > I found Python suppress deprecation warnings by default.
> > =

> > https://docs.python.org/3/library/warnings.html#warning-categories
> > https://docs.python.org/3/library/warnings.html#default-warning-filter
> =

> Please note the following at the second location:
> "Changed in version 3.7: DeprecationWarning is once again shown by defaul=
t when triggered directly by code in __main__."
> =

> So what Python currently does in issue depreciation warnings in the main =
program, but not in libraries and similar code. That may also be a reasonab=
le way to limit the number of warnings while making sure deprecations don't=
 go unnoticed (because that makes them useless).

Thank you for pointing that.

I think it's possible compromise in Ruby.

Although Ruby has no generic warning mechanism as Python,
I think hard-coding the condition
(show deprecation warnings only in main file by default)
is not difficult.





----------------------------------------
Feature #16345: Don't emit deprecation warnings by default.
https://bugs.ruby-lang.org/issues/16345#change-82670

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: =

* Target version: =

----------------------------------------
We propose that Ruby doesn't emit deprecation warnings by default.

Deprecation warnings are only useful during development for updating Ruby v=
ersion.
They are not useful during development with current Ruby.
It is especially frustrating when deprecated warnings are generated in gems.
Also, deprecation warnings are totally useless in production environment.

So, we want to emit deprecation warnings only in useful situations.

We propose a command line argument `-W:deprecated` (or `--warning=3Ddepreca=
ted`)
and the following methods to enable/disable deprecation warnings.

```ruby
Warning.disable(:deprecated)
Warning.enable(:deprecated)
Warning.enabled?(:deprecated)
```

Currently we don't propose a method to generate a deprecation warning
because currently our main intent is to disable deprecation warnings for =

keyword arguments, and the warnings are generated in C level.

Background:

We talked about keyword arguments during a developer meeting (2019-11-12).
https://bugs.ruby-lang.org/issues/16333
We expect many deprecation warnings to be generated in Ruby 2.7.
They are not useful except for development for Ruby transition, and
they may block transition to Ruby 2.7.

So, we have consensus to disable deprecation warnings by default.
Our design is intentionally minimum because we need this feature for Ruby 2=
.7.

We chose `Warning.disable(:deprecated)` instead of
re-defining `Warning.warn` in order to avoid string object generation.

Of course, we expect to extend this feature:
Ruby-level deprecation warning generation,
warnings other than deprecation, =

file-based restriction of warning generation, etc.
But this issue doesn't contain them.




-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>