diff options
author | 2017-12-11 16:27:29 -0800 | |
---|---|---|
committer | 2017-12-11 16:27:29 -0800 | |
commit | e2097f0cc9bf15dba3a3af9301284860770de274 (patch) | |
tree | edb4b7b9b94035c0d7c91e40995e7d0240de7ba2 /src/python/grpcio_testing/grpc_testing/_channel | |
parent | 0f6c518e3c241ee5bea529f4499e5bf35872e9e3 (diff) |
yapf-ize grpc_testing
Diffstat (limited to 'src/python/grpcio_testing/grpc_testing/_channel')
6 files changed, 47 insertions, 34 deletions
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/__init__.py b/src/python/grpcio_testing/grpc_testing/_channel/__init__.py index 8011975d0a..7a64cda889 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/__init__.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/__init__.py @@ -20,4 +20,6 @@ from grpc_testing._channel import _channel_state # pylint: disable=unused-argument def testing_channel(descriptors, time): return _channel.TestingChannel(time, _channel_state.State()) + + # pylint: enable=unused-argument diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_channel.py b/src/python/grpcio_testing/grpc_testing/_channel/_channel.py index fbd064db88..b015b8d738 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/_channel.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/_channel.py @@ -32,20 +32,28 @@ class TestingChannel(grpc_testing.Channel): def unsubscribe(self, callback): raise NotImplementedError() - def unary_unary( - self, method, request_serializer=None, response_deserializer=None): + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): return _multi_callable.UnaryUnary(method, self._state) - def unary_stream( - self, method, request_serializer=None, response_deserializer=None): + def unary_stream(self, + method, + request_serializer=None, + response_deserializer=None): return _multi_callable.UnaryStream(method, self._state) - def stream_unary( - self, method, request_serializer=None, response_deserializer=None): + def stream_unary(self, + method, + request_serializer=None, + response_deserializer=None): return _multi_callable.StreamUnary(method, self._state) - def stream_stream( - self, method, request_serializer=None, response_deserializer=None): + def stream_stream(self, + method, + request_serializer=None, + response_deserializer=None): return _multi_callable.StreamStream(method, self._state) def take_unary_unary(self, method_descriptor): @@ -59,4 +67,6 @@ class TestingChannel(grpc_testing.Channel): def take_stream_stream(self, method_descriptor): return _channel_rpc.stream_stream(self._state, method_descriptor) + + # pylint: enable=unused-argument diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py b/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py index 762b6a035b..54499b3b55 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py @@ -27,8 +27,8 @@ class _UnaryUnary(grpc_testing.UnaryUnaryChannelRpc): self._rpc_state.cancelled() def terminate(self, response, trailing_metadata, code, details): - self._rpc_state.terminate_with_response( - response, trailing_metadata, code, details) + self._rpc_state.terminate_with_response(response, trailing_metadata, + code, details) class _UnaryStream(grpc_testing.UnaryStreamChannelRpc): @@ -67,8 +67,8 @@ class _StreamUnary(grpc_testing.StreamUnaryChannelRpc): self._rpc_state.cancelled() def terminate(self, response, trailing_metadata, code, details): - self._rpc_state.terminate_with_response( - response, trailing_metadata, code, details) + self._rpc_state.terminate_with_response(response, trailing_metadata, + code, details) class _StreamStream(grpc_testing.StreamStreamChannelRpc): diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py b/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py index 569c41d79d..779d59e59a 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py @@ -25,11 +25,10 @@ class State(_common.ChannelHandler): self._condition = threading.Condition() self._rpc_states = collections.defaultdict(list) - def invoke_rpc( - self, method_full_rpc_name, invocation_metadata, requests, - requests_closed, timeout): - rpc_state = _rpc_state.State( - invocation_metadata, requests, requests_closed) + def invoke_rpc(self, method_full_rpc_name, invocation_metadata, requests, + requests_closed, timeout): + rpc_state = _rpc_state.State(invocation_metadata, requests, + requests_closed) with self._condition: self._rpc_states[method_full_rpc_name].append(rpc_state) self._condition.notify_all() diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py b/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py index fe69257f5b..32b2f361d3 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py @@ -16,6 +16,7 @@ import grpc from grpc_testing import _common from grpc_testing._channel import _invocation + # All per-call credentials parameters are unused by this test infrastructure. # pylint: disable=unused-argument class UnaryUnary(grpc.UnaryUnaryMultiCallable): @@ -26,20 +27,20 @@ class UnaryUnary(grpc.UnaryUnaryMultiCallable): def __call__(self, request, timeout=None, metadata=None, credentials=None): rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) + self._method_full_rpc_name, + _common.fuss_with_metadata(metadata), [request], True, timeout) return _invocation.blocking_unary_response(rpc_handler) def with_call(self, request, timeout=None, metadata=None, credentials=None): rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) + self._method_full_rpc_name, + _common.fuss_with_metadata(metadata), [request], True, timeout) return _invocation.blocking_unary_response_with_call(rpc_handler) def future(self, request, timeout=None, metadata=None, credentials=None): rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) + self._method_full_rpc_name, + _common.fuss_with_metadata(metadata), [request], True, timeout) return _invocation.future_call(rpc_handler) @@ -112,4 +113,6 @@ class StreamStream(grpc.StreamStreamMultiCallable): _common.fuss_with_metadata(metadata), [], False, timeout) _invocation.consume_requests(request_iterator, rpc_handler) return _invocation.ResponseIteratorCall(rpc_handler) + + # pylint: enable=unused-argument diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py b/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py index e1fa49a2a8..ee0233002d 100644 --- a/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py +++ b/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py @@ -63,23 +63,22 @@ class State(_common.ChannelRpcHandler): if self._code is grpc.StatusCode.OK: if self._responses: response = self._responses.pop(0) - return _common.ChannelRpcRead( - response, None, None, None) + return _common.ChannelRpcRead(response, None, None, + None) else: return _common.ChannelRpcRead( - None, self._trailing_metadata, - grpc.StatusCode.OK, self._details) + None, self._trailing_metadata, grpc.StatusCode.OK, + self._details) elif self._code is None: if self._responses: response = self._responses.pop(0) - return _common.ChannelRpcRead( - response, None, None, None) + return _common.ChannelRpcRead(response, None, None, + None) else: self._condition.wait() else: - return _common.ChannelRpcRead( - None, self._trailing_metadata, self._code, - self._details) + return _common.ChannelRpcRead(None, self._trailing_metadata, + self._code, self._details) def termination(self): with self._condition: @@ -150,8 +149,8 @@ class State(_common.ChannelRpcHandler): self._responses.append(response) self._condition.notify_all() - def terminate_with_response( - self, response, trailing_metadata, code, details): + def terminate_with_response(self, response, trailing_metadata, code, + details): with self._condition: if self._initial_metadata is None: self._initial_metadata = _common.FUSSED_EMPTY_METADATA |