You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by di...@apache.org on 2020/06/18 15:18:20 UTC

[airflow] branch v1-10-test updated: Make it possible to silence warnings from Airflow (#9208)

This is an automated email from the ASF dual-hosted git repository.

dimberman pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new 4343183  Make it possible to silence warnings from Airflow (#9208)
4343183 is described below

commit 4343183725cf3f4ca9d0fa7b562170668e8b89f1
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Thu Jun 11 11:51:17 2020 +0100

    Make it possible to silence warnings from Airflow (#9208)
    
    If we blindly set the warnings filter, it is _impossible_ to silence
    these warnings. This is the approach suggested in https://docs.python.org/3/library/warnings.html#overriding-the-default-filter
    
    (cherry picked from commit daed75260903119f8f5dc8ee493778c50b1a6a8f)
---
 airflow/configuration.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/airflow/configuration.py b/airflow/configuration.py
index c7347f2..5586de1 100644
--- a/airflow/configuration.py
+++ b/airflow/configuration.py
@@ -47,10 +47,11 @@ standard_library.install_aliases()
 log = LoggingMixin().log
 
 # show Airflow's deprecation warnings
-warnings.filterwarnings(
-    action='default', category=DeprecationWarning, module='airflow')
-warnings.filterwarnings(
-    action='default', category=PendingDeprecationWarning, module='airflow')
+if not sys.warnoptions:
+    warnings.filterwarnings(
+        action='default', category=DeprecationWarning, module='airflow')
+    warnings.filterwarnings(
+        action='default', category=PendingDeprecationWarning, module='airflow')
 
 
 def generate_fernet_key():