[Python-ideas] Deprecation utilities for the warnings module

Ilya Kulakov kulakov.ilya at gmail.com
Fri Sep 14 15:24:17 EDT 2018


Hi Anders,

If correctly understood your concern, it's about usage of stdlib's *Warning classes directly
that makes all warnings coming from different libraries indistinguishable.

I think that's not the case, since warnings.filterwarnings allows
to specify custom filter using a regular expression to match module names.
Therefore it's not redundant to subclass *Warning for namespacing alone.

> On Sep 13, 2018, at 11:07 PM, Anders Hovmöller <boxed at killingar.net> wrote:
> 
> 
>> I'd like to propose an extension for the warnings module
>> to address this problem.
> 
> I like all of that. The only issue I have with it is that the warnings module is designed to namespace depredations so you can turn them on per library and this code doesn’t seem to handle that. We really want to avoid libraries using these convenience functions instead of creating their own warning that can be properly filtered. 
> 
> I’m not sure what the solution to this would be. Maybe just accessing <yourmodule>.DeprecationWarning dynamically? Seems a bit magical though. 
> 
> / Anders



More information about the Python-ideas mailing list