Skip to content

Commit 846db70

Browse files
authored
Run Black on Generated libraries (#6666)
* blacken appveyor * Blacken all gen'd libraries not under PR
1 parent 498e128 commit 846db70

File tree

21 files changed

+354
-359
lines changed

21 files changed

+354
-359
lines changed

packages/google-cloud-python-speech/google/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
try:
1616
import pkg_resources
17+
1718
pkg_resources.declare_namespace(__name__)
1819
except ImportError:
1920
import pkgutil
21+
2022
__path__ = pkgutil.extend_path(__path__, __name__)

packages/google-cloud-python-speech/google/cloud/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
try:
1616
import pkg_resources
17+
1718
pkg_resources.declare_namespace(__name__)
1819
except ImportError:
1920
import pkgutil
21+
2022
__path__ = pkgutil.extend_path(__path__, __name__)

packages/google-cloud-python-speech/google/cloud/speech.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@
2020
from google.cloud.speech_v1 import enums
2121
from google.cloud.speech_v1 import types
2222

23-
__all__ = (
24-
'enums',
25-
'types',
26-
'SpeechClient',
27-
)
23+
__all__ = ("enums", "types", "SpeechClient")

packages/google-cloud-python-speech/google/cloud/speech_v1/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,4 @@ class SpeechClient(SpeechHelpers, speech_client.SpeechClient):
2727
types = types
2828

2929

30-
__all__ = (
31-
'enums',
32-
'SpeechClient',
33-
'types',
34-
)
30+
__all__ = ("enums", "SpeechClient", "types")

packages/google-cloud-python-speech/google/cloud/speech_v1/gapic/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class AudioEncoding(enum.IntEnum):
7171
RTP header is replaced with a single byte containing the block length.
7272
Only Speex wideband is supported. ``sample_rate_hertz`` must be 16000.
7373
"""
74+
7475
ENCODING_UNSPECIFIED = 0
7576
LINEAR16 = 1
7677
FLAC = 2
@@ -97,5 +98,6 @@ class SpeechEventType(enum.IntEnum):
9798
sent if ``single_utterance`` was set to ``true``, and is not used
9899
otherwise.
99100
"""
101+
100102
SPEECH_EVENT_UNSPECIFIED = 0
101103
END_OF_SINGLE_UTTERANCE = 1

packages/google-cloud-python-speech/google/cloud/speech_v1/gapic/speech_client.py

Lines changed: 85 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,18 @@
3535
from google.cloud.speech_v1.proto import cloud_speech_pb2_grpc
3636
from google.longrunning import operations_pb2
3737

38-
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
39-
'google-cloud-speech', ).version
38+
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-speech").version
4039

4140

4241
class SpeechClient(object):
4342
"""Service that implements Google Cloud Speech API."""
4443

45-
SERVICE_ADDRESS = 'speech.googleapis.com:443'
44+
SERVICE_ADDRESS = "speech.googleapis.com:443"
4645
"""The default address of the service."""
4746

4847
# The name of the interface for this client. This is the key used to
4948
# find the method configuration in the client_config dictionary.
50-
_INTERFACE_NAME = 'google.cloud.speech.v1.Speech'
49+
_INTERFACE_NAME = "google.cloud.speech.v1.Speech"
5150

5251
@classmethod
5352
def from_service_account_file(cls, filename, *args, **kwargs):
@@ -63,19 +62,20 @@ def from_service_account_file(cls, filename, *args, **kwargs):
6362
Returns:
6463
SpeechClient: The constructed client.
6564
"""
66-
credentials = service_account.Credentials.from_service_account_file(
67-
filename)
68-
kwargs['credentials'] = credentials
65+
credentials = service_account.Credentials.from_service_account_file(filename)
66+
kwargs["credentials"] = credentials
6967
return cls(*args, **kwargs)
7068

7169
from_service_account_json = from_service_account_file
7270

73-
def __init__(self,
74-
transport=None,
75-
channel=None,
76-
credentials=None,
77-
client_config=None,
78-
client_info=None):
71+
def __init__(
72+
self,
73+
transport=None,
74+
channel=None,
75+
credentials=None,
76+
client_config=None,
77+
client_info=None,
78+
):
7979
"""Constructor.
8080
8181
Args:
@@ -109,18 +109,19 @@ def __init__(self,
109109
# Raise deprecation warnings for things we want to go away.
110110
if client_config is not None:
111111
warnings.warn(
112-
'The `client_config` argument is deprecated.',
112+
"The `client_config` argument is deprecated.",
113113
PendingDeprecationWarning,
114-
stacklevel=2)
114+
stacklevel=2,
115+
)
115116
else:
116117
client_config = speech_client_config.config
117118

118119
if channel:
119120
warnings.warn(
120-
'The `channel` argument is deprecated; use '
121-
'`transport` instead.',
121+
"The `channel` argument is deprecated; use " "`transport` instead.",
122122
PendingDeprecationWarning,
123-
stacklevel=2)
123+
stacklevel=2,
124+
)
124125

125126
# Instantiate the transport.
126127
# The transport is responsible for handling serialization and
@@ -134,19 +135,19 @@ def __init__(self,
134135
else:
135136
if credentials:
136137
raise ValueError(
137-
'Received both a transport instance and '
138-
'credentials; these are mutually exclusive.')
138+
"Received both a transport instance and "
139+
"credentials; these are mutually exclusive."
140+
)
139141
self.transport = transport
140142
else:
141143
self.transport = speech_grpc_transport.SpeechGrpcTransport(
142-
address=self.SERVICE_ADDRESS,
143-
channel=channel,
144-
credentials=credentials,
144+
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
145145
)
146146

147147
if client_info is None:
148148
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
149-
gapic_version=_GAPIC_LIBRARY_VERSION, )
149+
gapic_version=_GAPIC_LIBRARY_VERSION
150+
)
150151
else:
151152
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
152153
self._client_info = client_info
@@ -156,7 +157,8 @@ def __init__(self,
156157
# (Ordinarily, these are the defaults specified in the `*_config.py`
157158
# file next to this one.)
158159
self._method_configs = google.api_core.gapic_v1.config.parse_method_configs(
159-
client_config['interfaces'][self._INTERFACE_NAME], )
160+
client_config["interfaces"][self._INTERFACE_NAME]
161+
)
160162

161163
# Save a dictionary of cached API call functions.
162164
# These are the actual callables which invoke the proper
@@ -165,12 +167,14 @@ def __init__(self,
165167
self._inner_api_calls = {}
166168

167169
# Service calls
168-
def recognize(self,
169-
config,
170-
audio,
171-
retry=google.api_core.gapic_v1.method.DEFAULT,
172-
timeout=google.api_core.gapic_v1.method.DEFAULT,
173-
metadata=None):
170+
def recognize(
171+
self,
172+
config,
173+
audio,
174+
retry=google.api_core.gapic_v1.method.DEFAULT,
175+
timeout=google.api_core.gapic_v1.method.DEFAULT,
176+
metadata=None,
177+
):
174178
"""
175179
Performs synchronous speech recognition: receive results after all audio
176180
has been sent and processed.
@@ -220,28 +224,29 @@ def recognize(self,
220224
ValueError: If the parameters are invalid.
221225
"""
222226
# Wrap the transport method to add retry and timeout logic.
223-
if 'recognize' not in self._inner_api_calls:
227+
if "recognize" not in self._inner_api_calls:
224228
self._inner_api_calls[
225-
'recognize'] = google.api_core.gapic_v1.method.wrap_method(
226-
self.transport.recognize,
227-
default_retry=self._method_configs['Recognize'].retry,
228-
default_timeout=self._method_configs['Recognize'].timeout,
229-
client_info=self._client_info,
230-
)
229+
"recognize"
230+
] = google.api_core.gapic_v1.method.wrap_method(
231+
self.transport.recognize,
232+
default_retry=self._method_configs["Recognize"].retry,
233+
default_timeout=self._method_configs["Recognize"].timeout,
234+
client_info=self._client_info,
235+
)
231236

232-
request = cloud_speech_pb2.RecognizeRequest(
233-
config=config,
234-
audio=audio,
237+
request = cloud_speech_pb2.RecognizeRequest(config=config, audio=audio)
238+
return self._inner_api_calls["recognize"](
239+
request, retry=retry, timeout=timeout, metadata=metadata
235240
)
236-
return self._inner_api_calls['recognize'](
237-
request, retry=retry, timeout=timeout, metadata=metadata)
238-
239-
def long_running_recognize(self,
240-
config,
241-
audio,
242-
retry=google.api_core.gapic_v1.method.DEFAULT,
243-
timeout=google.api_core.gapic_v1.method.DEFAULT,
244-
metadata=None):
241+
242+
def long_running_recognize(
243+
self,
244+
config,
245+
audio,
246+
retry=google.api_core.gapic_v1.method.DEFAULT,
247+
timeout=google.api_core.gapic_v1.method.DEFAULT,
248+
metadata=None,
249+
):
245250
"""
246251
Performs asynchronous speech recognition: receive results via the
247252
google.longrunning.Operations interface. Returns either an
@@ -302,35 +307,36 @@ def long_running_recognize(self,
302307
ValueError: If the parameters are invalid.
303308
"""
304309
# Wrap the transport method to add retry and timeout logic.
305-
if 'long_running_recognize' not in self._inner_api_calls:
310+
if "long_running_recognize" not in self._inner_api_calls:
306311
self._inner_api_calls[
307-
'long_running_recognize'] = google.api_core.gapic_v1.method.wrap_method(
308-
self.transport.long_running_recognize,
309-
default_retry=self._method_configs['LongRunningRecognize'].
310-
retry,
311-
default_timeout=self.
312-
_method_configs['LongRunningRecognize'].timeout,
313-
client_info=self._client_info,
314-
)
312+
"long_running_recognize"
313+
] = google.api_core.gapic_v1.method.wrap_method(
314+
self.transport.long_running_recognize,
315+
default_retry=self._method_configs["LongRunningRecognize"].retry,
316+
default_timeout=self._method_configs["LongRunningRecognize"].timeout,
317+
client_info=self._client_info,
318+
)
315319

316320
request = cloud_speech_pb2.LongRunningRecognizeRequest(
317-
config=config,
318-
audio=audio,
321+
config=config, audio=audio
322+
)
323+
operation = self._inner_api_calls["long_running_recognize"](
324+
request, retry=retry, timeout=timeout, metadata=metadata
319325
)
320-
operation = self._inner_api_calls['long_running_recognize'](
321-
request, retry=retry, timeout=timeout, metadata=metadata)
322326
return google.api_core.operation.from_gapic(
323327
operation,
324328
self.transport._operations_client,
325329
cloud_speech_pb2.LongRunningRecognizeResponse,
326330
metadata_type=cloud_speech_pb2.LongRunningRecognizeMetadata,
327331
)
328332

329-
def streaming_recognize(self,
330-
requests,
331-
retry=google.api_core.gapic_v1.method.DEFAULT,
332-
timeout=google.api_core.gapic_v1.method.DEFAULT,
333-
metadata=None):
333+
def streaming_recognize(
334+
self,
335+
requests,
336+
retry=google.api_core.gapic_v1.method.DEFAULT,
337+
timeout=google.api_core.gapic_v1.method.DEFAULT,
338+
metadata=None,
339+
):
334340
"""
335341
Performs bidirectional streaming speech recognition: receive results while
336342
sending audio. This method is only available via the gRPC API (not REST).
@@ -372,16 +378,16 @@ def streaming_recognize(self,
372378
ValueError: If the parameters are invalid.
373379
"""
374380
# Wrap the transport method to add retry and timeout logic.
375-
if 'streaming_recognize' not in self._inner_api_calls:
381+
if "streaming_recognize" not in self._inner_api_calls:
376382
self._inner_api_calls[
377-
'streaming_recognize'] = google.api_core.gapic_v1.method.wrap_method(
378-
self.transport.streaming_recognize,
379-
default_retry=self._method_configs['StreamingRecognize'].
380-
retry,
381-
default_timeout=self._method_configs['StreamingRecognize'].
382-
timeout,
383-
client_info=self._client_info,
384-
)
383+
"streaming_recognize"
384+
] = google.api_core.gapic_v1.method.wrap_method(
385+
self.transport.streaming_recognize,
386+
default_retry=self._method_configs["StreamingRecognize"].retry,
387+
default_timeout=self._method_configs["StreamingRecognize"].timeout,
388+
client_info=self._client_info,
389+
)
385390

386-
return self._inner_api_calls['streaming_recognize'](
387-
requests, retry=retry, timeout=timeout, metadata=metadata)
391+
return self._inner_api_calls["streaming_recognize"](
392+
requests, retry=retry, timeout=timeout, metadata=metadata
393+
)

packages/google-cloud-python-speech/google/cloud/speech_v1/gapic/speech_client_config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"google.cloud.speech.v1.Speech": {
44
"retry_codes": {
55
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
6-
"non_idempotent": []
6+
"non_idempotent": [],
77
},
88
"retry_params": {
99
"default": {
@@ -13,26 +13,26 @@
1313
"initial_rpc_timeout_millis": 1000000,
1414
"rpc_timeout_multiplier": 1.0,
1515
"max_rpc_timeout_millis": 1000000,
16-
"total_timeout_millis": 5000000
16+
"total_timeout_millis": 5000000,
1717
}
1818
},
1919
"methods": {
2020
"Recognize": {
2121
"timeout_millis": 200000,
2222
"retry_codes_name": "idempotent",
23-
"retry_params_name": "default"
23+
"retry_params_name": "default",
2424
},
2525
"LongRunningRecognize": {
2626
"timeout_millis": 200000,
2727
"retry_codes_name": "non_idempotent",
28-
"retry_params_name": "default"
28+
"retry_params_name": "default",
2929
},
3030
"StreamingRecognize": {
3131
"timeout_millis": 200000,
3232
"retry_codes_name": "idempotent",
33-
"retry_params_name": "default"
34-
}
35-
}
33+
"retry_params_name": "default",
34+
},
35+
},
3636
}
3737
}
3838
}

0 commit comments

Comments
 (0)