From f7103babd994574ee2f3c3dcd775f3937669aa7f Mon Sep 17 00:00:00 2001 From: ines Date: Sat, 26 May 2018 18:44:15 +0200 Subject: [PATCH] Only overwrite warnings filter if set explicitly (resolves #2369) This way, pre-defined warning filters are respected and users are still able to use the fine-grained warning settings if they like. --- spacy/errors.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index ad0518fca..b096ab719 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -302,7 +302,7 @@ def _get_warn_excl(arg): return [w_id.strip() for w_id in arg.split(',')] -SPACY_WARNING_FILTER = os.environ.get('SPACY_WARNING_FILTER', 'always') +SPACY_WARNING_FILTER = os.environ.get('SPACY_WARNING_FILTER') SPACY_WARNING_TYPES = _get_warn_types(os.environ.get('SPACY_WARNING_TYPES')) SPACY_WARNING_IGNORE = _get_warn_excl(os.environ.get('SPACY_WARNING_IGNORE')) @@ -329,5 +329,6 @@ def _warn(message, warn_type='user'): category = WARNINGS[warn_type] stack = inspect.stack()[-1] with warnings.catch_warnings(): - warnings.simplefilter(SPACY_WARNING_FILTER, category) + if SPACY_WARNING_FILTER: + warnings.simplefilter(SPACY_WARNING_FILTER, category) warnings.warn_explicit(message, category, stack[1], stack[2])