From ef7d5718c41f10f2e274966176d12fe172b18339 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 21 Aug 2018 11:46:45 -0700 Subject: [PATCH] Use lighter weight six for python3 compatibility We're seeing issues of `python-future`'s types leaking out of the presto client and causing bad interactions with other libraries. `future` wasn't actually being used for all that much and was easily replaced with (already used) `six`. Additionally, I made `typing` and `ipaddress` only install in python2.x, they are already standard library modules in the other supported python versions. --- prestodb/auth.py | 2 +- prestodb/dbapi.py | 3 --- prestodb/redirect.py | 6 ++---- setup.py | 16 ++++++++-------- tox.ini | 2 +- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/prestodb/auth.py b/prestodb/auth.py index c98596b..cf8afb9 100644 --- a/prestodb/auth.py +++ b/prestodb/auth.py @@ -16,7 +16,7 @@ import abc import os -from future.utils import with_metaclass +from six import with_metaclass from typing import Any, Optional, Text # NOQA import requests_kerberos diff --git a/prestodb/dbapi.py b/prestodb/dbapi.py index 3235f51..929819f 100644 --- a/prestodb/dbapi.py +++ b/prestodb/dbapi.py @@ -21,9 +21,6 @@ from __future__ import division from __future__ import print_function -from future.standard_library import install_aliases -install_aliases() - from typing import Any, List, Optional # NOQA for mypy types from prestodb import constants diff --git a/prestodb/redirect.py b/prestodb/redirect.py index 68dddd4..9e523ac 100644 --- a/prestodb/redirect.py +++ b/prestodb/redirect.py @@ -14,14 +14,12 @@ from __future__ import print_function import abc -from future.standard_library import install_aliases -install_aliases() -from future.utils import with_metaclass +from six import with_metaclass import ipaddress import socket from typing import Any, Text # NOQA -from urllib.parse import urlparse +from six.moves.urllib_parse import urlparse class RedirectHandler(with_metaclass(abc.ABCMeta)): # type: ignore diff --git a/setup.py b/setup.py index 162894b..ef52ef4 100644 --- a/setup.py +++ b/setup.py @@ -57,16 +57,16 @@ ], install_requires=[ 'click', - 'future', - 'ipaddress', 'requests', 'requests_kerberos', 'six', - 'typing', ], - extras_require={'tests':[ - 'httpretty', - 'pytest', - 'pytest-runner', - ]} + extras_require={ + 'tests':[ + 'httpretty', + 'pytest', + 'pytest-runner', + ], + ':python_version=="2.7"': ['ipaddress', 'typing'], + }, ) diff --git a/tox.ini b/tox.ini index 54d5b91..7793b20 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py35,py3.6,pypy2 +envlist = py27,py35,py36,pypy2 [testenv] deps = pytest