Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 778d27d

Browse files
chore(python): use black==22.3.0 (googleapis#362)
* 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 * ci: 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]>
1 parent 112049e commit 778d27d

16 files changed

+152
-70
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:6162c384d685c5fe22521d3f37f6fc732bf99a085f6d47b677dbcae97fc21392
16+
digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe

docs/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,13 @@
314314
# One entry per manual page. List of tuples
315315
# (source start file, name, description, authors, manual section).
316316
man_pages = [
317-
(root_doc, "google-api-core", "google-api-core Documentation", [author], 1,)
317+
(
318+
root_doc,
319+
"google-api-core",
320+
"google-api-core Documentation",
321+
[author],
322+
1,
323+
)
318324
]
319325

320326
# If true, show URL addresses after external links.
@@ -355,7 +361,10 @@
355361
intersphinx_mapping = {
356362
"python": ("https://python.readthedocs.org/en/latest/", None),
357363
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
358-
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
364+
"google.api_core": (
365+
"https://googleapis.dev/python/google-api-core/latest/",
366+
None,
367+
),
359368
"grpc": ("https://grpc.github.io/grpc/python/", None),
360369
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
361370
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),

google/api_core/datetime_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def from_rfc3339(value):
151151
micros = 0
152152
else:
153153
scale = 9 - len(fraction)
154-
nanos = int(fraction) * (10 ** scale)
154+
nanos = int(fraction) * (10**scale)
155155
micros = nanos // 1000
156156

157157
return bare_seconds.replace(microsecond=micros, tzinfo=datetime.timezone.utc)
@@ -245,7 +245,7 @@ def from_rfc3339(cls, stamp):
245245
nanos = 0
246246
else:
247247
scale = 9 - len(fraction)
248-
nanos = int(fraction) * (10 ** scale)
248+
nanos = int(fraction) * (10**scale)
249249
return cls(
250250
bare.year,
251251
bare.month,

google/api_core/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def details(self):
202202
203203
Returns:
204204
Sequence[Any]: A list of structured objects from error_details.proto
205-
"""
205+
"""
206206
return list(self._details)
207207

208208
@property
@@ -490,7 +490,9 @@ def from_http_response(response):
490490
error_info = error_info[0] if error_info else None
491491

492492
message = "{method} {url}: {error}".format(
493-
method=response.request.method, url=response.request.url, error=error_message,
493+
method=response.request.method,
494+
url=response.request.url,
495+
error=error_message,
494496
)
495497

496498
exception = from_http_status(

google/api_core/grpc_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def _create_composite_credentials(
246246

247247
# Create the metadata plugin for inserting the authorization header.
248248
metadata_plugin = google.auth.transport.grpc.AuthMetadataPlugin(
249-
credentials, request, default_host=default_host,
249+
credentials,
250+
request,
251+
default_host=default_host,
250252
)
251253

252254
# Create a set of grpc.CallCredentials using the metadata plugin.

google/api_core/operations_v1/abstract_operations_client.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class AbstractOperationsClientMeta(type):
4949
_transport_registry["rest"] = OperationsRestTransport
5050

5151
def get_transport_class(
52-
cls, label: Optional[str] = None,
52+
cls,
53+
label: Optional[str] = None,
5354
) -> Type[OperationsTransport]:
5455
"""Returns an appropriate transport class.
5556
@@ -165,7 +166,9 @@ def transport(self) -> OperationsTransport:
165166
return self._transport
166167

167168
@staticmethod
168-
def common_billing_account_path(billing_account: str,) -> str:
169+
def common_billing_account_path(
170+
billing_account: str,
171+
) -> str:
169172
"""Returns a fully-qualified billing_account string."""
170173
return "billingAccounts/{billing_account}".format(
171174
billing_account=billing_account,
@@ -178,9 +181,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
178181
return m.groupdict() if m else {}
179182

180183
@staticmethod
181-
def common_folder_path(folder: str,) -> str:
184+
def common_folder_path(
185+
folder: str,
186+
) -> str:
182187
"""Returns a fully-qualified folder string."""
183-
return "folders/{folder}".format(folder=folder,)
188+
return "folders/{folder}".format(
189+
folder=folder,
190+
)
184191

185192
@staticmethod
186193
def parse_common_folder_path(path: str) -> Dict[str, str]:
@@ -189,9 +196,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]:
189196
return m.groupdict() if m else {}
190197

191198
@staticmethod
192-
def common_organization_path(organization: str,) -> str:
199+
def common_organization_path(
200+
organization: str,
201+
) -> str:
193202
"""Returns a fully-qualified organization string."""
194-
return "organizations/{organization}".format(organization=organization,)
203+
return "organizations/{organization}".format(
204+
organization=organization,
205+
)
195206

196207
@staticmethod
197208
def parse_common_organization_path(path: str) -> Dict[str, str]:
@@ -200,9 +211,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]:
200211
return m.groupdict() if m else {}
201212

202213
@staticmethod
203-
def common_project_path(project: str,) -> str:
214+
def common_project_path(
215+
project: str,
216+
) -> str:
204217
"""Returns a fully-qualified project string."""
205-
return "projects/{project}".format(project=project,)
218+
return "projects/{project}".format(
219+
project=project,
220+
)
206221

207222
@staticmethod
208223
def parse_common_project_path(path: str) -> Dict[str, str]:
@@ -211,10 +226,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]:
211226
return m.groupdict() if m else {}
212227

213228
@staticmethod
214-
def common_location_path(project: str, location: str,) -> str:
229+
def common_location_path(
230+
project: str,
231+
location: str,
232+
) -> str:
215233
"""Returns a fully-qualified location string."""
216234
return "projects/{project}/locations/{location}".format(
217-
project=project, location=location,
235+
project=project,
236+
location=location,
218237
)
219238

220239
@staticmethod
@@ -406,12 +425,20 @@ def list_operations(
406425
)
407426

408427
# Send the request.
409-
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
428+
response = rpc(
429+
request,
430+
retry=retry,
431+
timeout=timeout,
432+
metadata=metadata,
433+
)
410434

411435
# This method is paged; wrap the response in a pager, which provides
412436
# an `__iter__` convenience method.
413437
response = pagers.ListOperationsPager(
414-
method=rpc, request=request, response=response, metadata=metadata,
438+
method=rpc,
439+
request=request,
440+
response=response,
441+
metadata=metadata,
415442
)
416443

417444
# Done; return the response.
@@ -459,7 +486,12 @@ def get_operation(
459486
)
460487

461488
# Send the request.
462-
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
489+
response = rpc(
490+
request,
491+
retry=retry,
492+
timeout=timeout,
493+
metadata=metadata,
494+
)
463495

464496
# Done; return the response.
465497
return response
@@ -506,7 +538,10 @@ def delete_operation(
506538

507539
# Send the request.
508540
rpc(
509-
request, retry=retry, timeout=timeout, metadata=metadata,
541+
request,
542+
retry=retry,
543+
timeout=timeout,
544+
metadata=metadata,
510545
)
511546

512547
def cancel_operation(
@@ -560,5 +595,8 @@ def cancel_operation(
560595

561596
# Send the request.
562597
rpc(
563-
request, retry=retry, timeout=timeout, metadata=metadata,
598+
request,
599+
retry=retry,
600+
timeout=timeout,
601+
metadata=metadata,
564602
)

google/api_core/operations_v1/transports/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ def _prep_wrapped_messages(self, client_info):
183183
def close(self):
184184
"""Closes resources associated with the transport.
185185
186-
.. warning::
187-
Only call this method if the transport is NOT shared
188-
with other clients - this may cause errors in other clients!
186+
.. warning::
187+
Only call this method if the transport is NOT shared
188+
with other clients - this may cause errors in other clients!
189189
"""
190190
raise NotImplementedError()
191191

google/api_core/path_template.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -239,26 +239,26 @@ def validate(tmpl, path):
239239

240240
def transcode(http_options, **request_kwargs):
241241
"""Transcodes a grpc request pattern into a proper HTTP request following the rules outlined here,
242-
https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312
243-
244-
Args:
245-
http_options (list(dict)): A list of dicts which consist of these keys,
246-
'method' (str): The http method
247-
'uri' (str): The path template
248-
'body' (str): The body field name (optional)
249-
(This is a simplified representation of the proto option `google.api.http`)
250-
251-
request_kwargs (dict) : A dict representing the request object
252-
253-
Returns:
254-
dict: The transcoded request with these keys,
255-
'method' (str) : The http method
256-
'uri' (str) : The expanded uri
257-
'body' (dict) : A dict representing the body (optional)
258-
'query_params' (dict) : A dict mapping query parameter variables and values
259-
260-
Raises:
261-
ValueError: If the request does not match the given template.
242+
https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312
243+
244+
Args:
245+
http_options (list(dict)): A list of dicts which consist of these keys,
246+
'method' (str): The http method
247+
'uri' (str): The path template
248+
'body' (str): The body field name (optional)
249+
(This is a simplified representation of the proto option `google.api.http`)
250+
251+
request_kwargs (dict) : A dict representing the request object
252+
253+
Returns:
254+
dict: The transcoded request with these keys,
255+
'method' (str) : The http method
256+
'uri' (str) : The expanded uri
257+
'body' (dict) : A dict representing the body (optional)
258+
'query_params' (dict) : A dict mapping query parameter variables and values
259+
260+
Raises:
261+
ValueError: If the request does not match the given template.
262262
"""
263263
for http_option in http_options:
264264
request = {}

google/api_core/rest_streaming.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def __init__(self, response: requests.Response, response_message_cls):
4848
self._escape_next = False
4949

5050
def cancel(self):
51-
"""Cancel existing streaming operation.
52-
"""
51+
"""Cancel existing streaming operation."""
5352
self._response.close()
5453

5554
def _process_chunk(self, chunk: str):

noxfile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import nox # pytype: disable=import-error
2222

2323

24-
BLACK_VERSION = "black==19.10b0"
24+
BLACK_VERSION = "black==22.3.0"
2525
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
2626
# Black and flake8 clash on the syntax for ignoring flake8's F401 in this file.
2727
BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"]
@@ -64,7 +64,10 @@ def lint(session):
6464
session.install("flake8", "flake8-import-order", BLACK_VERSION)
6565
session.install(".")
6666
session.run(
67-
"black", "--check", *BLACK_EXCLUDES, *BLACK_PATHS,
67+
"black",
68+
"--check",
69+
*BLACK_EXCLUDES,
70+
*BLACK_PATHS,
6871
)
6972
session.run("flake8", "google", "tests")
7073

tests/asyncio/gapic/test_method_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ async def test_wrap_method_with_default_retry_and_timeout_using_sentinel(unused_
162162
)
163163

164164
result = await wrapped_method(
165-
retry=gapic_v1.method_async.DEFAULT, timeout=gapic_v1.method_async.DEFAULT,
165+
retry=gapic_v1.method_async.DEFAULT,
166+
timeout=gapic_v1.method_async.DEFAULT,
166167
)
167168

168169
assert result == 42

0 commit comments

Comments
 (0)