From 3322782aa617f317f7a0c4c01dace5afc7e14889 Mon Sep 17 00:00:00 2001 From: Bas Harenslak Date: Sat, 25 May 2019 18:58:33 +0200 Subject: [PATCH] [AIRFLOW-4570] Remove future library (#5324) Remove all usage of the future library because we're dropping Python 2 support. --- airflow/api/auth/backend/kerberos_auth.py | 4 ---- airflow/api/client/json_client.py | 3 ++- airflow/configuration.py | 3 --- airflow/contrib/auth/backends/ldap_auth.py | 13 ++++--------- airflow/models/dag.py | 3 --- airflow/www/utils.py | 3 --- setup.py | 1 - 7 files changed, 6 insertions(+), 24 deletions(-) diff --git a/airflow/api/auth/backend/kerberos_auth.py b/airflow/api/auth/backend/kerberos_auth.py index f95f4d2571..8a6a76f018 100644 --- a/airflow/api/auth/backend/kerberos_auth.py +++ b/airflow/api/auth/backend/kerberos_auth.py @@ -24,8 +24,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from future.standard_library import install_aliases - from airflow.utils.log.logging_mixin import LoggingMixin import kerberos @@ -43,8 +41,6 @@ from functools import wraps from requests_kerberos import HTTPKerberosAuth from socket import getfqdn -install_aliases() - client_auth = HTTPKerberosAuth(service='airflow') _SERVICE_NAME = None diff --git a/airflow/api/client/json_client.py b/airflow/api/client/json_client.py index e05913ebb4..2b8440813a 100644 --- a/airflow/api/client/json_client.py +++ b/airflow/api/client/json_client.py @@ -17,7 +17,8 @@ # specific language governing permissions and limitations # under the License. -from future.moves.urllib.parse import urljoin +from urllib.parse import urljoin + import requests from airflow.api.client import api_client diff --git a/airflow/configuration.py b/airflow/configuration.py index 7e0f8ad8a5..af68c6bb77 100644 --- a/airflow/configuration.py +++ b/airflow/configuration.py @@ -21,7 +21,6 @@ from base64 import b64encode from builtins import str from collections import OrderedDict import copy -from future import standard_library import os import pathlib import shlex @@ -36,8 +35,6 @@ from zope.deprecation import deprecated from airflow.exceptions import AirflowConfigException from airflow.utils.log.logging_mixin import LoggingMixin -standard_library.install_aliases() - log = LoggingMixin().log # show Airflow's deprecation warnings diff --git a/airflow/contrib/auth/backends/ldap_auth.py b/airflow/contrib/auth/backends/ldap_auth.py index 1639f43aec..6729f9df2c 100644 --- a/airflow/contrib/auth/backends/ldap_auth.py +++ b/airflow/contrib/auth/backends/ldap_auth.py @@ -16,7 +16,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from future.utils import native import flask_login from flask_login import login_required, current_user, logout_user # noqa: F401 @@ -75,7 +74,7 @@ def get_ldap_connection(dn=None, password=None): use_ssl=True, tls=tls_configuration) - conn = Connection(server, native(dn), native(password)) + conn = Connection(server, dn, password) if not conn.bind(): log.error("Cannot bind to ldap server: %s ", conn.last_error) @@ -87,8 +86,7 @@ def get_ldap_connection(dn=None, password=None): def group_contains_user(conn, search_base, group_filter, user_name_attr, username): search_filter = '(&({0}))'.format(group_filter) - if not conn.search(native(search_base), native(search_filter), - attributes=[native(user_name_attr)]): + if not conn.search(search_base, search_filter, attributes=[user_name_attr]): log.warning("Unable to find group for %s %s", search_base, search_filter) else: for entry in conn.entries: @@ -105,8 +103,7 @@ def groups_user(conn, search_base, user_filter, user_name_att, username): memberof_attr = configuration.conf.get("ldap", "group_member_attr") except Exception: memberof_attr = "memberOf" - res = conn.search(native(search_base), native(search_filter), - attributes=[native(memberof_attr)]) + res = conn.search(search_base, search_filter, attributes=[memberof_attr]) if not res: log.info("Cannot find user %s", username) raise AuthenticationError("Invalid username or password") @@ -210,9 +207,7 @@ class LdapUser(models.User): # todo: BASE or ONELEVEL? - res = conn.search(native(configuration.conf.get("ldap", "basedn")), - native(search_filter), - search_scope=native(search_scope)) + res = conn.search(configuration.conf.get("ldap", "basedn"), search_filter, search_scope=search_scope) # todo: use list or result? if not res: diff --git a/airflow/models/dag.py b/airflow/models/dag.py index 3c337d97c4..b25d6c2d57 100644 --- a/airflow/models/dag.py +++ b/airflow/models/dag.py @@ -34,7 +34,6 @@ import pendulum import six from croniter import croniter from dateutil.relativedelta import relativedelta -from future.standard_library import install_aliases from sqlalchemy import Column, String, Boolean, Integer, Text, func, or_ from airflow import configuration, settings, utils @@ -54,8 +53,6 @@ from airflow.utils.log.logging_mixin import LoggingMixin from airflow.utils.sqlalchemy import UtcDateTime, Interval from airflow.utils.state import State -install_aliases() - ScheduleInterval = Union[str, timedelta, relativedelta] diff --git a/airflow/www/utils.py b/airflow/www/utils.py index e097499e38..39498691e9 100644 --- a/airflow/www/utils.py +++ b/airflow/www/utils.py @@ -17,9 +17,6 @@ # specific language governing permissions and limitations # under the License. -from future import standard_library # noqa -standard_library.install_aliases() # noqa - import inspect import json import time diff --git a/setup.py b/setup.py index 6970bcd326..7a67635c71 100644 --- a/setup.py +++ b/setup.py @@ -323,7 +323,6 @@ def do_setup(): 'flask-swagger==0.2.13', 'flask-wtf>=0.14.2, <0.15', 'funcsigs==1.0.0', - 'future>=0.16.0, <0.17', 'gitpython>=2.0.2', 'gunicorn>=19.5.0, <20.0', 'iso8601>=0.1.12',