Skip to content

Commit be6c2b7

Browse files
authored
chore: Update Python versions, remove six (#111)
* Update Python versions, remove six
1 parent c97c203 commit be6c2b7

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

google_auth_httplib2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
from __future__ import absolute_import
1818

19+
import http.client
1920
import logging
2021

2122
from google.auth import exceptions
2223
from google.auth import transport
2324
import httplib2
24-
from six.moves import http_client
2525

2626

2727
_LOGGER = logging.getLogger(__name__)
@@ -122,7 +122,7 @@ def __call__(
122122
return _Response(response, data)
123123
# httplib2 should catch the lower http error, this is a bug and
124124
# needs to be fixed there. Catch the error for the meanwhile.
125-
except (httplib2.HttpLib2Error, http_client.HTTPException) as exc:
125+
except (httplib2.HttpLib2Error, http.client.HTTPException) as exc:
126126
raise exceptions.TransportError(exc)
127127

128128

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
]
2828

2929
DEFAULT_PYTHON_VERSION = "3.8"
30-
UNIT_TEST_PYTHON_VERSIONS = ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
30+
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
3131

3232

3333
@nox.session(python=DEFAULT_PYTHON_VERSION)

pylint.config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
'function-rgx': '[a-z_][a-z0-9_]{2,40}$',
4646
},
4747
'TYPECHECK': {
48-
'ignored-modules': ['six', 'google.protobuf'],
48+
'ignored-modules': ['google.protobuf'],
4949
},
5050
'DESIGN': {
5151
'min-public-methods': '0',

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
version = "0.1.0"
2020

21-
DEPENDENCIES = ["google-auth", "httplib2 >= 0.15.0", "six"]
21+
DEPENDENCIES = ["google-auth", "httplib2 >= 0.15.0"]
2222

2323

2424
with io.open("README.rst", "r") as fh:
@@ -38,13 +38,13 @@
3838
license="Apache 2.0",
3939
keywords="google auth oauth client",
4040
classifiers=[
41-
"Programming Language :: Python :: 2",
42-
"Programming Language :: Python :: 2.7",
4341
"Programming Language :: Python :: 3",
44-
"Programming Language :: Python :: 3.5",
4542
"Programming Language :: Python :: 3.6",
4643
"Programming Language :: Python :: 3.7",
4744
"Programming Language :: Python :: 3.8",
45+
"Programming Language :: Python :: 3.9",
46+
"Programming Language :: Python :: 3.10",
47+
"Programming Language :: Python :: 3.11",
4848
"Development Status :: 3 - Alpha",
4949
"Intended Audience :: Developers",
5050
"License :: OSI Approved :: Apache Software License",

tests/compliance.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import http.client
16+
1517
import flask
1618
from google.auth import exceptions
1719
import pytest
1820
from pytest_localserver.http import WSGIServer
19-
from six.moves import http_client
2021

2122
# .invalid will never resolve, see https://tools.ietf.org/html/rfc2606
2223
NXDOMAIN = "test.invalid"
@@ -40,11 +41,11 @@ def server(self):
4041
def index():
4142
header_value = flask.request.headers.get("x-test-header", "value")
4243
headers = {"X-Test-Header": header_value}
43-
return "Basic Content", http_client.OK, headers
44+
return "Basic Content", http.client.OK, headers
4445

4546
@app.route("/server_error")
4647
def server_error():
47-
return "Error", http_client.INTERNAL_SERVER_ERROR
48+
return "Error", http.client.INTERNAL_SERVER_ERROR
4849

4950
# pylint: enable=unused-variable
5051

@@ -57,15 +58,15 @@ def test_request_basic(self, server):
5758
request = self.make_request()
5859
response = request(url=server.url + "/basic", method="GET")
5960

60-
assert response.status == http_client.OK
61+
assert response.status == http.client.OK
6162
assert response.headers["x-test-header"] == "value"
6263
assert response.data == b"Basic Content"
6364

6465
def test_request_timeout(self, server):
6566
request = self.make_request()
6667
response = request(url=server.url + "/basic", method="GET", timeout=2)
6768

68-
assert response.status == http_client.OK
69+
assert response.status == http.client.OK
6970
assert response.headers["x-test-header"] == "value"
7071
assert response.data == b"Basic Content"
7172

@@ -77,15 +78,15 @@ def test_request_headers(self, server):
7778
headers={"x-test-header": "hello world"},
7879
)
7980

80-
assert response.status == http_client.OK
81+
assert response.status == http.client.OK
8182
assert response.headers["x-test-header"] == "hello world"
8283
assert response.data == b"Basic Content"
8384

8485
def test_request_error(self, server):
8586
request = self.make_request()
8687
response = request(url=server.url + "/server_error", method="GET")
8788

88-
assert response.status == http_client.INTERNAL_SERVER_ERROR
89+
assert response.status == http.client.INTERNAL_SERVER_ERROR
8990
assert response.data == b"Error"
9091

9192
def test_connection_error(self):

tests/test_google_auth_httplib2.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import http.client
16+
import io
17+
1518
import httplib2
1619
import mock
17-
import six
18-
from six.moves import http_client
1920

2021
import google_auth_httplib2
2122
from tests import compliance
@@ -44,7 +45,7 @@ def request(
4445

4546

4647
class MockResponse(object):
47-
def __init__(self, status=http_client.OK, data=b""):
48+
def __init__(self, status=http.client.OK, data=b""):
4849
self.status = status
4950
self.data = data
5051

@@ -180,10 +181,10 @@ def test_request_no_refresh(self):
180181

181182
def test_request_refresh(self):
182183
mock_credentials = mock.Mock(wraps=MockCredentials())
183-
mock_final_response = MockResponse(status=http_client.OK)
184+
mock_final_response = MockResponse(status=http.client.OK)
184185
# First request will 401, second request will succeed.
185186
mock_http = MockHttp(
186-
[MockResponse(status=http_client.UNAUTHORIZED), mock_final_response]
187+
[MockResponse(status=http.client.UNAUTHORIZED), mock_final_response]
187188
)
188189

189190
authed_http = google_auth_httplib2.AuthorizedHttp(
@@ -220,10 +221,10 @@ def test_request_stream_body(self):
220221
mock_response = MockResponse()
221222
# Refresh is needed to cover the resetting of the body position.
222223
mock_http = MockHttp(
223-
[MockResponse(status=http_client.UNAUTHORIZED), mock_response]
224+
[MockResponse(status=http.client.UNAUTHORIZED), mock_response]
224225
)
225226

226-
body = six.StringIO("body")
227+
body = io.StringIO("body")
227228
body.seek(1)
228229

229230
authed_http = google_auth_httplib2.AuthorizedHttp(

0 commit comments

Comments
 (0)