Merge pull request #9866 from nathanielmanistaatgoogle/lint-fixes

Lint fixes.
pull/9969/head
Nathaniel Manista 8 years ago committed by GitHub
commit 0ee3e3ec2d
  1. 10
      .pylintrc
  2. 24
      src/python/grpcio/grpc/_auth.py
  3. 2
      src/python/grpcio/grpc/_channel.py
  4. 2
      src/python/grpcio/grpc/_server.py
  5. 1
      src/python/grpcio/grpc/beta/_client_adaptations.py
  6. 7
      src/python/grpcio/grpc/beta/implementations.py
  7. 2
      src/python/grpcio/grpc/framework/foundation/logging_pool.py

@ -1,3 +1,8 @@
[VARIABLES]
# TODO(https://github.com/PyCQA/pylint/issues/1345): How does the inspection
# not include "unused_" and "ignored_" by default?
dummy-variables-rgx=^ignored_|^unused_
[MESSAGES CONTROL] [MESSAGES CONTROL]
#TODO: Enable missing-docstring #TODO: Enable missing-docstring
@ -15,9 +20,7 @@
#TODO: Enable wrong-import-order #TODO: Enable wrong-import-order
#TODO: Enable no-value-for-parameter #TODO: Enable no-value-for-parameter
#TODO: Enable cyclic-import #TODO: Enable cyclic-import
#TODO: Enable unused-variable
#TODO: Enable redefined-outer-name #TODO: Enable redefined-outer-name
#TODO: Enable unused-import
#TODO: Enable too-many-instance-attributes #TODO: Enable too-many-instance-attributes
#TODO: Enable broad-except #TODO: Enable broad-except
#TODO: Enable too-many-locals #TODO: Enable too-many-locals
@ -29,6 +32,5 @@
#TODO: Enable too-many-return-statements #TODO: Enable too-many-return-statements
#TODO: Enable too-many-nested-blocks #TODO: Enable too-many-nested-blocks
#TODO: Enable super-init-not-called #TODO: Enable super-init-not-called
#TODO: Enable no-self-use
disable=missing-docstring,too-few-public-methods,too-many-arguments,no-init,duplicate-code,invalid-name,suppressed-message,locally-disabled,protected-access,no-name-in-module,unused-argument,fixme,wrong-import-order,no-value-for-parameter,cyclic-import,unused-variable,redefined-outer-name,unused-import,too-many-instance-attributes,broad-except,too-many-locals,too-many-lines,redefined-variable-type,next-method-called,import-error,useless-else-on-loop,too-many-return-statements,too-many-nested-blocks,super-init-not-called,no-self-use disable=missing-docstring,too-few-public-methods,too-many-arguments,no-init,duplicate-code,invalid-name,suppressed-message,locally-disabled,protected-access,no-name-in-module,unused-argument,fixme,wrong-import-order,no-value-for-parameter,cyclic-import,redefined-outer-name,too-many-instance-attributes,broad-except,too-many-locals,too-many-lines,redefined-variable-type,next-method-called,import-error,useless-else-on-loop,too-many-return-statements,too-many-nested-blocks,super-init-not-called

@ -39,6 +39,19 @@ def _sign_request(callback, token, error):
callback(metadata, error) callback(metadata, error)
def _create_get_token_callback(callback):
def get_token_callback(future):
try:
access_token = future.result().access_token
except Exception as exception:
_sign_request(callback, None, exception)
else:
_sign_request(callback, access_token, None)
return get_token_callback
class GoogleCallCredentials(grpc.AuthMetadataPlugin): class GoogleCallCredentials(grpc.AuthMetadataPlugin):
"""Metadata wrapper for GoogleCredentials from the oauth2client library.""" """Metadata wrapper for GoogleCredentials from the oauth2client library."""
@ -59,16 +72,7 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin):
additional_claims={'aud': context.service_url}) additional_claims={'aud': context.service_url})
else: else:
future = self._pool.submit(self._credentials.get_access_token) future = self._pool.submit(self._credentials.get_access_token)
future.add_done_callback( future.add_done_callback(_create_get_token_callback(callback))
lambda x: self._get_token_callback(callback, x))
def _get_token_callback(self, callback, future):
try:
access_token = future.result().access_token
except Exception as e:
_sign_request(callback, None, e)
else:
_sign_request(callback, access_token, None)
def __del__(self): def __del__(self):
self._pool.shutdown(wait=False) self._pool.shutdown(wait=False)

@ -200,7 +200,7 @@ def _consume_request_iterator(request_iterator, state, call,
request = next(request_iterator) request = next(request_iterator)
except StopIteration: except StopIteration:
break break
except Exception as e: except Exception:
logging.exception("Exception iterating requests!") logging.exception("Exception iterating requests!")
call.cancel() call.cancel()
_abort(state, grpc.StatusCode.UNKNOWN, _abort(state, grpc.StatusCode.UNKNOWN,

@ -342,7 +342,7 @@ def _unary_request(rpc_event, state, request_deserializer):
if state.client is _CANCELLED or state.statused: if state.client is _CANCELLED or state.statused:
return None return None
else: else:
start_server_batch_result = rpc_event.operation_call.start_server_batch( rpc_event.operation_call.start_server_batch(
cygrpc.Operations( cygrpc.Operations(
(cygrpc.operation_receive_message(_EMPTY_FLAGS),)), (cygrpc.operation_receive_message(_EMPTY_FLAGS),)),
_receive_message(state, rpc_event.operation_call, _receive_message(state, rpc_event.operation_call,

@ -30,7 +30,6 @@
import grpc import grpc
from grpc import _common from grpc import _common
from grpc._cython import cygrpc
from grpc.beta import interfaces from grpc.beta import interfaces
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
from grpc.framework.foundation import future from grpc.framework.foundation import future

@ -29,16 +29,15 @@
"""Entry points into the Beta API of gRPC Python.""" """Entry points into the Beta API of gRPC Python."""
# threading is referenced from specification in this module. # threading is referenced from specification in this module.
import abc
import enum
import threading # pylint: disable=unused-import import threading # pylint: disable=unused-import
# cardinality and face are referenced from specification in this module. # interfaces, cardinality, and face are referenced from specification in this
# module.
import grpc import grpc
from grpc import _auth from grpc import _auth
from grpc.beta import _client_adaptations from grpc.beta import _client_adaptations
from grpc.beta import _server_adaptations from grpc.beta import _server_adaptations
from grpc.beta import interfaces from grpc.beta import interfaces # pylint: disable=unused-import
from grpc.framework.common import cardinality # pylint: disable=unused-import from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import from grpc.framework.interfaces.face import face # pylint: disable=unused-import

@ -39,7 +39,7 @@ def _wrap(behavior):
def _wrapping(*args, **kwargs): def _wrapping(*args, **kwargs):
try: try:
return behavior(*args, **kwargs) return behavior(*args, **kwargs)
except Exception as e: except Exception:
logging.exception( logging.exception(
'Unexpected exception from %s executed in logging pool!', 'Unexpected exception from %s executed in logging pool!',
behavior) behavior)

Loading…
Cancel
Save