Run yapf over Python code

pull/9127/head
Masood Malekghassemi 8 years ago
parent 0b1bb2d418
commit 6b890d1dd3
  1. 12
      src/python/grpcio/commands.py
  2. 4
      src/python/grpcio/grpc/_channel.py
  3. 4
      src/python/grpcio_tests/commands.py
  4. 4
      src/python/grpcio_tests/tests/_loader.py
  5. 4
      src/python/grpcio_tests/tests/_runner.py
  6. 15
      src/python/grpcio_tests/tests/interop/methods.py
  7. 8
      src/python/grpcio_tests/tests/qps/worker_server.py
  8. 4
      src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
  9. 8
      src/python/grpcio_tests/tests/unit/_empty_message_test.py

@ -271,12 +271,12 @@ class BuildExt(build_ext.build_ext):
compiler = self.compiler.compiler_type compiler = self.compiler.compiler_type
if compiler in BuildExt.C_OPTIONS: if compiler in BuildExt.C_OPTIONS:
for extension in self.extensions: for extension in self.extensions:
extension.extra_compile_args += list(BuildExt.C_OPTIONS[ extension.extra_compile_args += list(
compiler]) BuildExt.C_OPTIONS[compiler])
if compiler in BuildExt.LINK_OPTIONS: if compiler in BuildExt.LINK_OPTIONS:
for extension in self.extensions: for extension in self.extensions:
extension.extra_link_args += list(BuildExt.LINK_OPTIONS[ extension.extra_link_args += list(
compiler]) BuildExt.LINK_OPTIONS[compiler])
if not check_and_update_cythonization(self.extensions): if not check_and_update_cythonization(self.extensions):
self.extensions = try_cythonize(self.extensions) self.extensions = try_cythonize(self.extensions)
try: try:
@ -284,8 +284,8 @@ class BuildExt(build_ext.build_ext):
except Exception as error: except Exception as error:
formatted_exception = traceback.format_exc() formatted_exception = traceback.format_exc()
support.diagnose_build_ext_error(self, error, formatted_exception) support.diagnose_build_ext_error(self, error, formatted_exception)
raise CommandError("Failed `build_ext` step:\n{}".format( raise CommandError(
formatted_exception)) "Failed `build_ext` step:\n{}".format(formatted_exception))
class Gather(setuptools.Command): class Gather(setuptools.Command):

@ -842,8 +842,8 @@ def _poll_connectivity(state, channel, initial_try_to_connect):
connectivity = channel.check_connectivity_state(try_to_connect) connectivity = channel.check_connectivity_state(try_to_connect)
with state.lock: with state.lock:
state.connectivity = ( state.connectivity = (
_common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY[ _common.
connectivity]) CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY[connectivity])
callbacks = tuple(callback callbacks = tuple(callback
for callback, unused_but_known_to_be_none_connectivity for callback, unused_but_known_to_be_none_connectivity
in state.callbacks_and_connectivities) in state.callbacks_and_connectivities)

@ -121,8 +121,8 @@ class BuildProtoModules(setuptools.Command):
'--grpc_python_out={}'.format(PROTO_STEM), '--grpc_python_out={}'.format(PROTO_STEM),
] + [path] ] + [path]
if protoc.main(command) != 0: if protoc.main(command) != 0:
sys.stderr.write('warning: Command:\n{}\nFailed'.format( sys.stderr.write(
command)) 'warning: Command:\n{}\nFailed'.format(command))
# Generated proto directories dont include __init__.py, but # Generated proto directories dont include __init__.py, but
# these are needed for python package resolution # these are needed for python package resolution

@ -116,5 +116,5 @@ def iterate_suite_cases(suite):
elif isinstance(item, unittest.TestCase): elif isinstance(item, unittest.TestCase):
yield item yield item
else: else:
raise ValueError('unexpected suite item of type {}'.format( raise ValueError(
type(item))) 'unexpected suite item of type {}'.format(type(item)))

@ -196,8 +196,8 @@ class Runner(object):
# Run the tests # Run the tests
result.startTestRun() result.startTestRun()
for augmented_case in augmented_cases: for augmented_case in augmented_cases:
sys.stdout.write('Running {}\n'.format(augmented_case.case.id( sys.stdout.write(
))) 'Running {}\n'.format(augmented_case.case.id()))
sys.stdout.flush() sys.stdout.flush()
case_thread = threading.Thread( case_thread = threading.Thread(
target=augmented_case.case.run, args=(result,)) target=augmented_case.case.run, args=(result,))

@ -428,8 +428,8 @@ def _compute_engine_creds(stub, args):
def _oauth2_auth_token(stub, args): def _oauth2_auth_token(stub, args):
json_key_filename = os.environ[ json_key_filename = os.environ[oauth2client_client.
oauth2client_client.GOOGLE_APPLICATION_CREDENTIALS] GOOGLE_APPLICATION_CREDENTIALS]
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email'] wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
response = _large_unary_common_behavior(stub, True, True, None) response = _large_unary_common_behavior(stub, True, True, None)
if wanted_email != response.username: if wanted_email != response.username:
@ -441,8 +441,8 @@ def _oauth2_auth_token(stub, args):
def _jwt_token_creds(stub, args): def _jwt_token_creds(stub, args):
json_key_filename = os.environ[ json_key_filename = os.environ[oauth2client_client.
oauth2client_client.GOOGLE_APPLICATION_CREDENTIALS] GOOGLE_APPLICATION_CREDENTIALS]
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email'] wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
response = _large_unary_common_behavior(stub, True, False, None) response = _large_unary_common_behavior(stub, True, False, None)
if wanted_email != response.username: if wanted_email != response.username:
@ -451,11 +451,10 @@ def _jwt_token_creds(stub, args):
def _per_rpc_creds(stub, args): def _per_rpc_creds(stub, args):
json_key_filename = os.environ[ json_key_filename = os.environ[oauth2client_client.
oauth2client_client.GOOGLE_APPLICATION_CREDENTIALS] GOOGLE_APPLICATION_CREDENTIALS]
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email'] wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
credentials = oauth2client_client.GoogleCredentials.get_application_default( credentials = oauth2client_client.GoogleCredentials.get_application_default()
)
scoped_credentials = credentials.create_scoped([args.oauth_scope]) scoped_credentials = credentials.create_scoped([args.oauth_scope])
# TODO(https://github.com/grpc/grpc/issues/6799): Eliminate this last # TODO(https://github.com/grpc/grpc/issues/6799): Eliminate this last
# remaining use of the Beta API. # remaining use of the Beta API.

@ -102,8 +102,8 @@ class WorkerServer(services_pb2.WorkerServiceServicer):
'grpc.testing.BenchmarkService', method_implementations) 'grpc.testing.BenchmarkService', method_implementations)
server.add_generic_rpc_handlers((handler,)) server.add_generic_rpc_handlers((handler,))
else: else:
raise Exception('Unsupported server type {}'.format( raise Exception(
config.server_type)) 'Unsupported server type {}'.format(config.server_type))
if config.HasField('security_params'): # Use SSL if config.HasField('security_params'): # Use SSL
server_creds = grpc.ssl_server_credentials(( server_creds = grpc.ssl_server_credentials((
@ -171,8 +171,8 @@ class WorkerServer(services_pb2.WorkerServiceServicer):
else: else:
raise Exception('Async streaming client not supported') raise Exception('Async streaming client not supported')
else: else:
raise Exception('Unsupported client type {}'.format( raise Exception(
config.client_type)) 'Unsupported client type {}'.format(config.client_type))
# In multi-channel tests, we split the load across all channels # In multi-channel tests, we split the load across all channels
load_factor = float(config.client_channels) load_factor = float(config.client_channels)

@ -204,8 +204,8 @@ class ServerClientMixin(object):
self.assertTrue(event.success) self.assertTrue(event.success)
self.assertIs(tag, event.tag) self.assertIs(tag, event.tag)
except Exception as error: except Exception as error:
raise Exception("Error in '{}': {}".format(description, raise Exception(
error.message)) "Error in '{}': {}".format(description, error.message))
return event return event
return test_utilities.SimpleFuture(performer) return test_utilities.SimpleFuture(performer)

@ -122,13 +122,13 @@ class EmptyMessageTest(unittest.TestCase):
list(response_iterator)) list(response_iterator))
def testStreamUnary(self): def testStreamUnary(self):
response = self._channel.stream_unary(_STREAM_UNARY)(iter( response = self._channel.stream_unary(_STREAM_UNARY)(
[_REQUEST] * test_constants.STREAM_LENGTH)) iter([_REQUEST] * test_constants.STREAM_LENGTH))
self.assertEqual(_RESPONSE, response) self.assertEqual(_RESPONSE, response)
def testStreamStream(self): def testStreamStream(self):
response_iterator = self._channel.stream_stream(_STREAM_STREAM)(iter( response_iterator = self._channel.stream_stream(_STREAM_STREAM)(
[_REQUEST] * test_constants.STREAM_LENGTH)) iter([_REQUEST] * test_constants.STREAM_LENGTH))
self.assertSequenceEqual([_RESPONSE] * test_constants.STREAM_LENGTH, self.assertSequenceEqual([_RESPONSE] * test_constants.STREAM_LENGTH,
list(response_iterator)) list(response_iterator))

Loading…
Cancel
Save