[FIX] core: improve warnings configuration

DeprecationWarning was configured as `once` which might be why I
missed some previously: `once` means the *filter* will only signal
once, meaning only one DeprecationWarning gets shown per run. Even if
there are 5 *completely different* warnings getting generated by the
codebase.

`default` should be more suitable, I think I'd originally
misunderstood it as "whatever the default is for this warning" but
what it *actually* means is "print once for each (module, lineno)".

An alternative could be `module` which would show the warning once per
module but wouldn't trigger from different warnings in the same module.
This commit is contained in:
Xavier Morel
2020-04-22 09:27:29 +00:00
parent 92b007cb89
commit 3f2a18b0f2
+1 -1
View File
@@ -126,7 +126,7 @@ def init_logger():
logging.setLogRecordFactory(record_factory)
# enable deprecation warnings (disabled by default)
warnings.filterwarnings('once', category=DeprecationWarning)
warnings.filterwarnings('default', category=DeprecationWarning)
# ignore deprecation warnings from invalid escape (there's a ton and it's
# pretty likely a super low-value signal)
warnings.filterwarnings('ignore', r'^invalid escape sequence \\.', category=DeprecationWarning)