On Thu, Sep 15, 2016 at 03:09:44PM +0100, Simon King wrote:
> According to
https://docs.python.org/2/using/cmdline.html#cmdoption-W,
> the full form of -W (and PYTHONWARNINGS) is:
>
> action:message:category:module:line
>
> Empty fields are ignored, and unused trailing fields can be left out,
> so maybe "error::SAWarning" would work?
The problem with this is that -W and PYTHONWARNINGS are evaluated
*before* any user code gets imported, which means there is no
SAWarning at that time, so this doesn't work. At least it didn't work
for me when I was trying to do this myself a few months ago, and I
found this as an explanation. (I didn't save a reference, though,
unfortunately.)
What I ended up doing was to enable all warnings, and then whitelist
some of them one by one (IIRC, I only had to restore the default
behavior for ImportError and DeprecationWarning, but I'm not entirely
certain anymore – I'm pretty sure it wasn't more than a small handful,
though, of course, this will also depend on the packages you use).
Good luck,
Michal