Skip to content

Commit f5e9c65

Browse files
authored
fix!: drop support for Python 2.7 (#43)
Drop use of 'six' Drop use of 'mock' shim module Closes #42.
1 parent 284a721 commit f5e9c65

File tree

7 files changed

+29
-38
lines changed

7 files changed

+29
-38
lines changed

setup.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,12 @@
4040
entry_points={"console_scripts": scripts},
4141
platforms="Posix; MacOS X; Windows",
4242
include_package_data=True,
43-
install_requires=(
44-
"google-auth >= 0.4.0",
45-
"six>=1.9.0",
46-
"click>=7.0.0",
47-
"packaging>=19.0",
48-
),
49-
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
43+
install_requires=("google-auth >= 0.4.0", "click>=7.0.0", "packaging>=19.0"),
44+
python_requires=">=3.6",
5045
classifiers=[
5146
"Development Status :: 4 - Beta",
5247
"Intended Audience :: Developers",
5348
"Operating System :: OS Independent",
54-
"Programming Language :: Python :: 2",
55-
"Programming Language :: Python :: 2.7",
5649
"Programming Language :: Python :: 3",
5750
"Programming Language :: Python :: 3.6",
5851
"Programming Language :: Python :: 3.7",

test_utils/imports.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import mock
16-
import six
15+
import builtins
16+
from unittest import mock
1717

1818

1919
def maybe_fail_import(predicate):
@@ -28,11 +28,11 @@ def maybe_fail_import(predicate):
2828
Returns:
2929
A mock patcher object that can be used to enable patched import behavior.
3030
"""
31-
orig_import = six.moves.builtins.__import__
31+
orig_import = builtins.__import__
3232

3333
def custom_import(name, globals=None, locals=None, fromlist=(), level=0):
3434
if predicate(name, globals, locals, fromlist, level):
3535
raise ImportError
3636
return orig_import(name, globals, locals, fromlist, level)
3737

38-
return mock.patch.object(six.moves.builtins, "__import__", new=custom_import)
38+
return mock.patch.object(builtins, "__import__", new=custom_import)

test_utils/retry.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import functools
1516
import time
1617

17-
import six
18-
1918
MAX_TRIES = 4
2019
DELAY = 1
2120
BACKOFF = 2
@@ -51,7 +50,7 @@ def __init__(self, max_tries=MAX_TRIES, delay=DELAY, backoff=BACKOFF, logger=Non
5150
self.max_tries = max_tries
5251
self.delay = delay
5352
self.backoff = backoff
54-
self.logger = logger.warning if logger else six.print_
53+
self.logger = logger.warning if logger else print
5554

5655

5756
class RetryErrors(RetryBase):
@@ -93,7 +92,7 @@ def __init__(
9392
self.error_predicate = error_predicate
9493

9594
def __call__(self, to_wrap):
96-
@six.wraps(to_wrap)
95+
@functools.wraps(to_wrap)
9796
def wrapped_function(*args, **kwargs):
9897
tries = 0
9998
while tries < self.max_tries:
@@ -151,7 +150,7 @@ def __init__(
151150
self.result_predicate = result_predicate
152151

153152
def __call__(self, to_wrap):
154-
@six.wraps(to_wrap)
153+
@functools.wraps(to_wrap)
155154
def wrapped_function(*args, **kwargs):
156155
tries = 0
157156
while tries < self.max_tries:
@@ -208,7 +207,7 @@ def __init__(
208207
def __call__(self, to_wrap):
209208
instance = to_wrap.__self__ # only instance methods allowed
210209

211-
@six.wraps(to_wrap)
210+
@functools.wraps(to_wrap)
212211
def wrapped_function(*args, **kwargs):
213212
tries = 0
214213
while tries < self.max_tries:

testing/constraints-3.6.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
click==7.0.0
22
google-auth==0.4.0
33
packaging==19.0
4-
six==1.9.0
5-
colorlog==3.0.0
4+
colorlog==3.0.0

tests/unit/resources/bad_package/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
requirements = [
1919
"requests", # no lower bound
2020
"packaging>=14.0, !=15.0, <22.0.0", # too complex for tool
21-
"six<2.0.0", # no lower bound
21+
"wheel<0.36.0",
2222
"click==7.0.0",
2323
]
2424

tests/unit/resources/good_package/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
requirements = [
2222
"requests>=1.0.0",
2323
"packaging>=14.0, <22.0.0",
24-
"six<2.0.0, >=1.0.0",
24+
"wheel<0.36.0, >=0.35.0",
2525
"click==7.0.0",
2626
]
2727

tests/unit/test_lower_bound_checker.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ def test_update_constraints():
8888

8989
output = constraints_path.read_text().split("\n")
9090

91-
assert output == ["click==7.0.0", "grpcio==1.0.0", "packaging==14.0", "requests==1.0.0", "six==1.0.0",]
91+
assert output == ["click==7.0.0", "grpcio==1.0.0", "packaging==14.0", "requests==1.0.0", "wheel==0.35.0",]
9292

9393

9494

9595
def test_update_constraints_overwrites_existing_file():
9696
constraints = [
9797
"requests==1.0.0",
9898
"packaging==13.0",
99-
"six==1.6.0",
99+
"wheel==0.36.0",
100100
"click==5.0.0",
101101
]
102102
with constraints_file(constraints) as c:
@@ -107,14 +107,14 @@ def test_update_constraints_overwrites_existing_file():
107107
assert result.exit_code == 0
108108

109109
output = c.read_text().split("\n")
110-
assert output == ["click==7.0.0", "grpcio==1.0.0", "packaging==14.0", "requests==1.0.0", "six==1.0.0",
110+
assert output == ["click==7.0.0", "grpcio==1.0.0", "packaging==14.0", "requests==1.0.0", "wheel==0.35.0",
111111
]
112112

113113
def test_update_constraints_with_setup_py_missing_lower_bounds():
114114
constraints = [
115115
"requests==1.0.0",
116116
"packaging==14.0",
117-
"six==1.0.0",
117+
"wheel==0.35.0",
118118
"click==7.0.0",
119119
]
120120
with constraints_file(constraints) as c:
@@ -126,15 +126,15 @@ def test_update_constraints_with_setup_py_missing_lower_bounds():
126126
assert "setup.py is missing explicit lower bounds" in result.output
127127

128128
invalid_pkg_list = parse_error_msg(result.output)
129-
assert set(invalid_pkg_list) == {"requests", "packaging", "six"}
129+
assert set(invalid_pkg_list) == {"requests", "packaging", "wheel"}
130130

131131

132132

133133
def test_check():
134134
constraints = [
135135
"requests==1.0.0",
136136
"packaging==14.0",
137-
"six==1.0.0",
137+
"wheel==0.35.0",
138138
"click==7.0.0",
139139
"grpcio==1.0.0"
140140
]
@@ -150,7 +150,7 @@ def test_update_constraints_with_extra_constraints():
150150
constraints = [
151151
"requests==1.0.0",
152152
"packaging==14.0",
153-
"six==1.0.0",
153+
"wheel==0.35.0",
154154
"click==7.0.0",
155155
"grpcio==1.0.0",
156156
"pytest==6.0.0", # additional requirement
@@ -182,7 +182,7 @@ def test_check_with_constraints_file_invalid_pins():
182182
constraints = [
183183
"requests==1.0.0",
184184
"packaging==14.0",
185-
"six==1.0.0, <2.0.0dev", # should be ==
185+
"wheel==1.0.0, <2.0.0dev", # should be ==
186186
"click>=7.0.0", # should be ==
187187
]
188188
with constraints_file(constraints) as c:
@@ -194,14 +194,14 @@ def test_check_with_constraints_file_invalid_pins():
194194

195195
invalid_pkg_list = parse_error_msg(result.output)
196196

197-
assert set(invalid_pkg_list) == {"six", "click"}
197+
assert set(invalid_pkg_list) == {"wheel", "click"}
198198

199199

200200
def test_check_with_constraints_file_missing_packages():
201201
constraints = [
202202
"requests==1.0.0",
203203
"packaging==14.0",
204-
# missing 'six' and 'click' and extra 'grpcio'
204+
# missing 'wheel' and 'click' and extra 'grpcio'
205205
]
206206
with constraints_file(constraints) as c:
207207
result = RUNNER.invoke(
@@ -211,14 +211,14 @@ def test_check_with_constraints_file_missing_packages():
211211
assert result.exit_code == 2
212212

213213
invalid_pkg_list = parse_error_msg(result.output)
214-
assert set(invalid_pkg_list) == {"six", "click", "grpcio"}
214+
assert set(invalid_pkg_list) == {"wheel", "click", "grpcio"}
215215

216216

217217
def test_check_with_constraints_file_different_versions():
218218
constraints = [
219219
"requests==1.2.0", # setup.py has 1.0.0
220220
"packaging==14.1", # setup.py has 14.0
221-
"six==1.4.0", # setup.py has 1.0.0
221+
"wheel==0.36.0", # setup.py has 0.35.0
222222
"click==7.0.0",
223223
"grpcio==1.0.0"
224224
]
@@ -230,14 +230,14 @@ def test_check_with_constraints_file_different_versions():
230230
assert result.exit_code == 2
231231

232232
invalid_pkg_list = parse_diff_versions_error_msg(result.output)
233-
assert set(invalid_pkg_list) == {"requests", "packaging", "six"}
233+
assert set(invalid_pkg_list) == {"requests", "packaging", "wheel"}
234234

235235

236236
def test_check_with_setup_py_missing_lower_bounds():
237237
constraints = [
238238
"requests==1.0.0",
239239
"packaging==14.0",
240-
"six==1.0.0",
240+
"wheel==1.0.0",
241241
"click==7.0.0",
242242
]
243243
with constraints_file(constraints) as c:
@@ -248,4 +248,4 @@ def test_check_with_setup_py_missing_lower_bounds():
248248
assert result.exit_code == 2
249249

250250
invalid_pkg_list = parse_error_msg(result.output)
251-
assert set(invalid_pkg_list) == {"requests", "packaging", "six"}
251+
assert set(invalid_pkg_list) == {"requests", "packaging", "wheel"}

0 commit comments

Comments
 (0)