From e4be530d24fe4f0c645f837027e7441ed63fb24a Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 2 May 2018 16:04:29 +0200 Subject: [PATCH 1/2] [AIRFLOW-2407] Use feature detection for reload() [Use feature detection instead of version detection](https://docs.python.org/3/howto/pyporting.html#use-feature-detection-instead-of-version-detection) is a Python porting best practice that avoids a flake8 undefined name error... flake8 testing of https://github.com/apache/incubator-airflow on Python 3.6.3 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./airflow/www/app.py:148:17: F821 undefined name 'reload' reload(e) ^ ``` --- airflow/www/app.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/airflow/www/app.py b/airflow/www/app.py index ca0589d669a2b..cd98cb3dff400 100644 --- a/airflow/www/app.py +++ b/airflow/www/app.py @@ -144,11 +144,11 @@ def integrate_plugins(): # required for testing purposes otherwise the module retains # a link to the default_auth if app.config['TESTING']: - if six.PY2: - reload(e) - else: - import importlib - importlib.reload(e) + try: + reload # Python 2 + except NameError: # Python 3 + from importlib import reload + reload(e) app.register_blueprint(e.api_experimental, url_prefix='/api/experimental') From 2a307f52004500be795f28e61fad491a257939e8 Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 13 Jul 2018 08:11:19 +0200 Subject: [PATCH 2/2] six.moves.reload_module(e) --- airflow/www/app.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/airflow/www/app.py b/airflow/www/app.py index cd98cb3dff400..e9b2c35db32af 100644 --- a/airflow/www/app.py +++ b/airflow/www/app.py @@ -144,11 +144,7 @@ def integrate_plugins(): # required for testing purposes otherwise the module retains # a link to the default_auth if app.config['TESTING']: - try: - reload # Python 2 - except NameError: # Python 3 - from importlib import reload - reload(e) + six.moves.reload_module(e) app.register_blueprint(e.api_experimental, url_prefix='/api/experimental')