Skip to content

Commit

Permalink
chore(python): use black==22.3.0 (#742)
Browse files Browse the repository at this point in the history
* chore(python): use black==22.3.0

Source-Link: googleapis/synthtool@6fab84a
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe

* chore(python): use black==22.3.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
3 people authored Mar 30, 2022
1 parent a8fcebb commit ad39116
Show file tree
Hide file tree
Showing 28 changed files with 527 additions and 237 deletions.
2 changes: 1 addition & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae
digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@
intersphinx_mapping = {
"python": ("https://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"google.api_core": (
"https://googleapis.dev/python/google-api-core/latest/",
None,
),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/storage/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def _get_storage_host():

def _get_environ_project():
return os.getenv(
environment_vars.PROJECT, os.getenv(environment_vars.LEGACY_PROJECT),
environment_vars.PROJECT,
os.getenv(environment_vars.LEGACY_PROJECT),
)


Expand Down
2 changes: 1 addition & 1 deletion google/cloud/storage/_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_expiration_seconds_v2(expiration):
# If it's a datetime, convert to a timestamp.
if isinstance(expiration, datetime.datetime):
micros = _helpers._microseconds_from_datetime(expiration)
expiration = micros // 10 ** 6
expiration = micros // 10**6

if not isinstance(expiration, int):
raise TypeError(
Expand Down
5 changes: 4 additions & 1 deletion google/cloud/storage/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
self.entities.clear()

found = client._get_resource(
path, query_params=query_params, timeout=timeout, retry=retry,
path,
query_params=query_params,
timeout=timeout,
retry=retry,
)
self.loaded = True

Expand Down
12 changes: 6 additions & 6 deletions google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@


_API_ACCESS_ENDPOINT = "https://storage.googleapis.com"
_DEFAULT_CONTENT_TYPE = u"application/octet-stream"
_DOWNLOAD_URL_TEMPLATE = u"{hostname}/download/storage/v1{path}?alt=media"
_BASE_UPLOAD_TEMPLATE = u"{hostname}/upload/storage/v1{bucket_path}/o?uploadType="
_MULTIPART_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + u"multipart"
_RESUMABLE_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + u"resumable"
_DEFAULT_CONTENT_TYPE = "application/octet-stream"
_DOWNLOAD_URL_TEMPLATE = "{hostname}/download/storage/v1{path}?alt=media"
_BASE_UPLOAD_TEMPLATE = "{hostname}/upload/storage/v1{bucket_path}/o?uploadType="
_MULTIPART_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + "multipart"
_RESUMABLE_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + "resumable"
# NOTE: "acl" is also writeable but we defer ACL management to
# the classes in the google.cloud.storage.acl module.
_CONTENT_TYPE_FIELD = "contentType"
Expand Down Expand Up @@ -4459,7 +4459,7 @@ def _raise_from_invalid_response(error):
else:
error_message = str(error)

message = u"{method} {url}: {error}".format(
message = "{method} {url}: {error}".format(
method=response.request.method, url=response.request.url, error=error_message
)

Expand Down
8 changes: 6 additions & 2 deletions google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,10 @@ def list_notifications(
client = self._require_client(client)
path = self.path + "/notificationConfigs"
iterator = client._list_resource(
path, _item_to_notification, timeout=timeout, retry=retry,
path,
_item_to_notification,
timeout=timeout,
retry=retry,
)
iterator.bucket = self
return iterator
Expand Down Expand Up @@ -2952,7 +2955,8 @@ def make_public(
for blob in blobs:
blob.acl.all().grant_read()
blob.acl.save(
client=client, timeout=timeout,
client=client,
timeout=timeout,
)

def make_private(
Expand Down
10 changes: 8 additions & 2 deletions google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,9 @@ def download_blob_to_file(
headers = _get_encryption_headers(blob_or_uri._encryption_key)
headers["accept-encoding"] = "gzip"
_add_etag_match_headers(
headers, if_etag_match=if_etag_match, if_etag_not_match=if_etag_not_match,
headers,
if_etag_match=if_etag_match,
if_etag_not_match=if_etag_not_match,
)
headers = {**_get_default_headers(self._connection.user_agent), **headers}

Expand Down Expand Up @@ -1475,7 +1477,11 @@ def create_hmac_key(
qs_params["userProject"] = user_project

api_response = self._post_resource(
path, None, query_params=qs_params, timeout=timeout, retry=retry,
path,
None,
query_params=qs_params,
timeout=timeout,
retry=retry,
)
metadata = HMACKeyMetadata(self)
metadata._properties = api_response["metadata"]
Expand Down
21 changes: 17 additions & 4 deletions google/cloud/storage/hmac_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ def exists(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
qs_params["userProject"] = self.user_project

self._client._get_resource(
self.path, query_params=qs_params, timeout=timeout, retry=retry,
self.path,
query_params=qs_params,
timeout=timeout,
retry=retry,
)
except NotFound:
return False
Expand Down Expand Up @@ -239,7 +242,10 @@ def reload(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
qs_params["userProject"] = self.user_project

self._properties = self._client._get_resource(
self.path, query_params=qs_params, timeout=timeout, retry=retry,
self.path,
query_params=qs_params,
timeout=timeout,
retry=retry,
)

def update(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY_IF_ETAG_IN_JSON):
Expand All @@ -263,7 +269,11 @@ def update(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY_IF_ETAG_IN_JSON):

payload = {"state": self.state}
self._properties = self._client._put_resource(
self.path, payload, query_params=qs_params, timeout=timeout, retry=retry,
self.path,
payload,
query_params=qs_params,
timeout=timeout,
retry=retry,
)

def delete(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
Expand All @@ -289,5 +299,8 @@ def delete(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
qs_params["userProject"] = self.user_project

self._client._delete_resource(
self.path, query_params=qs_params, timeout=timeout, retry=retry,
self.path,
query_params=qs_params,
timeout=timeout,
retry=retry,
)
33 changes: 21 additions & 12 deletions google/cloud/storage/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,22 @@ def topic_name(self):

@property
def topic_project(self):
"""Project ID of topic to which notifications are published.
"""
"""Project ID of topic to which notifications are published."""
return self._topic_project

@property
def custom_attributes(self):
"""Custom attributes passed with notification events.
"""
"""Custom attributes passed with notification events."""
return self._properties.get("custom_attributes")

@property
def event_types(self):
"""Event types for which notification events are published.
"""
"""Event types for which notification events are published."""
return self._properties.get("event_types")

@property
def blob_name_prefix(self):
"""Prefix of blob names for which notification events are published.
"""
"""Prefix of blob names for which notification events are published."""
return self._properties.get("object_name_prefix")

@property
Expand Down Expand Up @@ -278,7 +274,11 @@ def create(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=None):
)

self._properties = client._post_resource(
path, properties, query_params=query_params, timeout=timeout, retry=retry,
path,
properties,
query_params=query_params,
timeout=timeout,
retry=retry,
)

def exists(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
Expand Down Expand Up @@ -318,7 +318,10 @@ def exists(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):

try:
client._get_resource(
self.path, query_params=query_params, timeout=timeout, retry=retry,
self.path,
query_params=query_params,
timeout=timeout,
retry=retry,
)
except NotFound:
return False
Expand Down Expand Up @@ -360,7 +363,10 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
query_params["userProject"] = self.bucket.user_project

response = client._get_resource(
self.path, query_params=query_params, timeout=timeout, retry=retry,
self.path,
query_params=query_params,
timeout=timeout,
retry=retry,
)
self._set_properties(response)

Expand Down Expand Up @@ -400,7 +406,10 @@ def delete(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
query_params["userProject"] = self.bucket.user_project

client._delete_resource(
self.path, query_params=query_params, timeout=timeout, retry=retry,
self.path,
query_params=query_params,
timeout=timeout,
retry=retry,
)


Expand Down
9 changes: 6 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import nox


BLACK_VERSION = "black==19.10b0"
BLACK_VERSION = "black==22.3.0"
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

DEFAULT_PYTHON_VERSION = "3.8"
Expand All @@ -46,7 +46,9 @@ def lint(session):
"""
session.install("flake8", BLACK_VERSION)
session.run(
"black", "--check", *BLACK_PATHS,
"black",
"--check",
*BLACK_PATHS,
)
session.run("flake8", "google", "tests")

Expand All @@ -59,7 +61,8 @@ def blacken(session):
"""
session.install(BLACK_VERSION)
session.run(
"black", *BLACK_PATHS,
"black",
*BLACK_PATHS,
)


Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# WARNING - WARNING - WARNING - WARNING - WARNING
# WARNING - WARNING - WARNING - WARNING - WARNING

BLACK_VERSION = "black==19.10b0"
BLACK_VERSION = "black==22.3.0"

# Copy `noxfile_config.py` to your directory and modify it instead.

Expand Down
12 changes: 5 additions & 7 deletions tests/perf/storage_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class StorageBenchWrapperStub(object):
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
Args:
channel: A grpc.Channel.
"""
self.Write = channel.unary_unary(
"/storage_bench.StorageBenchWrapper/Write",
request_serializer=storage__pb2.ObjectWrite.SerializeToString,
Expand All @@ -31,15 +31,13 @@ class StorageBenchWrapperServicer(object):
pass

def Write(self, request, context):
"""Performs an upload from a specific object.
"""
"""Performs an upload from a specific object."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def Read(self, request, context):
"""Read a specific object.
"""
"""Read a specific object."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")
Expand Down
4 changes: 3 additions & 1 deletion tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def listable_bucket(storage_client, listable_bucket_name, file_data):

for filename in _listable_filenames[1:]:
_helpers.retry_bad_copy(bucket.copy_blob)(
source_blob, bucket, filename,
source_blob,
bucket,
filename,
)

yield bucket
Expand Down
Loading

0 comments on commit ad39116

Please sign in to comment.