Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 173
feat!: Remove Python 2 support#657
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d43397a
Remove Python 2 support from setup.py and noxfile.py
andrewsg b18036e
Remove Py2 compatibility code, except in system tests
andrewsg dd2e602
Remove Py2 compatibility code in system tests
andrewsg 2e2789f
Remove six from setup.py
andrewsg 6d75717
Remove Py2.7 constraints file
andrewsg 21e0afb
Update README
andrewsg 590d2c7
Merge branch 'main' into python-2-turndown
andrewsg 047759a
Merge branch 'main' into python-2-turndown
andrewsg ca43eae
respond to feedback
andrewsg fd5d62d
remove kokoro presubmit for 2.7
andrewsg bc1f70b
Update README.rst
andrewsg ff290c3
Merge branch 'main' into python-2-turndown
andrewsg d2359fb
Merge branch 'main' into python-2-turndown
andrewsg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,7 +20,8 @@ | ||
| import hashlib | ||
| import json | ||
| import six | ||
| import http | ||
andrewsg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| import urllib | ||
| import google.auth.credentials | ||
| @@ -110,15 +111,15 @@ def get_expiration_seconds_v2(expiration): | ||
| micros = _helpers._microseconds_from_datetime(expiration) | ||
| expiration = micros // 10 ** 6 | ||
| if not isinstance(expiration, six.integer_types): | ||
| if not isinstance(expiration, int): | ||
| raise TypeError( | ||
| "Expected an integer timestamp, datetime, or " | ||
| "timedelta. Got %s" % type(expiration) | ||
| ) | ||
| return expiration | ||
| _EXPIRATION_TYPES = six.integer_types + (datetime.datetime, datetime.timedelta) | ||
| _EXPIRATION_TYPES = (int, datetime.datetime, datetime.timedelta) | ||
| def get_expiration_seconds_v4(expiration): | ||
| @@ -142,7 +143,7 @@ def get_expiration_seconds_v4(expiration): | ||
| now = NOW().replace(tzinfo=_helpers.UTC) | ||
| if isinstance(expiration, six.integer_types): | ||
| if isinstance(expiration, int): | ||
| seconds = expiration | ||
| if isinstance(expiration, datetime.datetime): | ||
| @@ -250,7 +251,7 @@ def canonicalize_v2(method, resource, query_parameters, headers): | ||
| (key.lower(), value and value.strip() or "") | ||
| for key, value in query_parameters.items() | ||
| ) | ||
| encoded_qp = six.moves.urllib.parse.urlencode(normalized_qp) | ||
| encoded_qp = urllib.parse.urlencode(normalized_qp) | ||
| canonical_resource = "{}?{}".format(resource, encoded_qp) | ||
| return _Canonical(method, canonical_resource, normalized_qp, headers) | ||
| @@ -410,7 +411,7 @@ def generate_signed_url_v2( | ||
| return "{endpoint}{resource}?{querystring}".format( | ||
| endpoint=api_access_endpoint, | ||
| resource=resource, | ||
| querystring=six.moves.urllib.parse.urlencode(sorted_signed_query_params), | ||
| querystring=urllib.parse.urlencode(sorted_signed_query_params), | ||
| ) | ||
| @@ -563,7 +564,7 @@ def generate_signed_url_v4( | ||
| header_names = [key.lower() for key in headers] | ||
| if "host" not in header_names: | ||
| headers["Host"] = six.moves.urllib.parse.urlparse(api_access_endpoint).netloc | ||
| headers["Host"] = urllib.parse.urlparse(api_access_endpoint).netloc | ||
| if method.upper() == "RESUMABLE": | ||
| method = "POST" | ||
| @@ -686,7 +687,7 @@ def _sign_message(message, access_token, service_account_email): | ||
| request = requests.Request() | ||
| response = request(url=url, method=method, body=body, headers=headers) | ||
| if response.status != six.moves.http_client.OK: | ||
| if response.status != http.client.OK: | ||
| raise exceptions.TransportError( | ||
| "Error calling the IAM signBytes API: {}".format(response.data) | ||
| ) | ||
| @@ -723,4 +724,4 @@ def _quote_param(param): | ||
| """ | ||
| if not isinstance(param, bytes): | ||
| param = str(param) | ||
| return six.moves.urllib.parse.quote(param, safe="~") | ||
| return urllib.parse.quote(param, safe="~") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -35,15 +35,13 @@ | ||
| import mimetypes | ||
| import os | ||
| import re | ||
| from urllib.parse import parse_qsl | ||
| from urllib.parse import quote | ||
| from urllib.parse import urlencode | ||
| from urllib.parse import urlsplit | ||
| from urllib.parse import urlunsplit | ||
andrewsg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| import warnings | ||
| import six | ||
| from six.moves.urllib.parse import parse_qsl | ||
| from six.moves.urllib.parse import quote | ||
| from six.moves.urllib.parse import urlencode | ||
| from six.moves.urllib.parse import urlsplit | ||
| from six.moves.urllib.parse import urlunsplit | ||
| from google import resumable_media | ||
| from google.resumable_media.requests import ChunkedDownload | ||
| from google.resumable_media.requests import Download | ||
| @@ -64,7 +62,6 @@ | ||
| from google.cloud.storage._helpers import _PropertyMixin | ||
| from google.cloud.storage._helpers import _scalar_property | ||
| from google.cloud.storage._helpers import _bucket_bound_hostname_url | ||
| from google.cloud.storage._helpers import _convert_to_timestamp | ||
| from google.cloud.storage._helpers import _raise_if_more_than_one_set | ||
| from google.cloud.storage._helpers import _api_core_retry_to_resumable_media_retry | ||
| from google.cloud.storage._signing import generate_signed_url_v2 | ||
| @@ -1303,10 +1300,7 @@ def download_to_filename( | ||
| updated = self.updated | ||
| if updated is not None: | ||
| if six.PY2: | ||
| mtime = _convert_to_timestamp(updated) | ||
| else: | ||
| mtime = updated.timestamp() | ||
| mtime = updated.timestamp() | ||
| os.utime(file_obj.name, (mtime, mtime)) | ||
| def download_as_bytes( | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,11 +18,9 @@ | ||
| import copy | ||
| import datetime | ||
| import json | ||
| from urllib.parse import urlsplit | ||
andrewsg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| import warnings | ||
| import six | ||
| from six.moves.urllib.parse import urlsplit | ||
| from google.api_core import datetime_helpers | ||
| from google.cloud._helpers import _datetime_to_rfc3339 | ||
| from google.cloud._helpers import _NOW | ||
| @@ -1705,7 +1703,7 @@ def delete_blobs( | ||
| for blob in blobs: | ||
| try: | ||
| blob_name = blob | ||
| if not isinstance(blob_name, six.string_types): | ||
| if not isinstance(blob_name, str): | ||
| blob_name = blob.name | ||
| self.delete_blob( | ||
| blob_name, | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.