Fix and enable no-member lint

pull/9830/head
Nathaniel Manista 8 years ago
parent 81f81c26f6
commit 90798ab199
  1. 3
      .pylintrc
  2. 7
      src/python/grpcio/grpc/_channel.py
  3. 4
      src/python/grpcio/grpc/_common.py
  4. 21
      src/python/grpcio/grpc/_server.py

@ -30,6 +30,5 @@
#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 #TODO: Enable no-self-use
#TODO: Enable no-member
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,no-member 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

@ -43,7 +43,6 @@ _USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__)
_EMPTY_FLAGS = 0 _EMPTY_FLAGS = 0
_INFINITE_FUTURE = cygrpc.Timespec(float('+inf')) _INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))
_EMPTY_METADATA = cygrpc.Metadata(())
_UNARY_UNARY_INITIAL_DUE = (cygrpc.OperationType.send_initial_metadata, _UNARY_UNARY_INITIAL_DUE = (cygrpc.OperationType.send_initial_metadata,
cygrpc.OperationType.send_message, cygrpc.OperationType.send_message,
@ -138,8 +137,8 @@ def _abort(state, code, details):
state.code = code state.code = code
state.details = details state.details = details
if state.initial_metadata is None: if state.initial_metadata is None:
state.initial_metadata = _EMPTY_METADATA state.initial_metadata = _common.EMPTY_METADATA
state.trailing_metadata = _EMPTY_METADATA state.trailing_metadata = _common.EMPTY_METADATA
def _handle_event(event, state, response_deserializer): def _handle_event(event, state, response_deserializer):
@ -435,7 +434,7 @@ def _start_unary_request(request, timeout, request_serializer):
deadline, deadline_timespec = _deadline(timeout) deadline, deadline_timespec = _deadline(timeout)
serialized_request = _common.serialize(request, request_serializer) serialized_request = _common.serialize(request, request_serializer)
if serialized_request is None: if serialized_request is None:
state = _RPCState((), _EMPTY_METADATA, _EMPTY_METADATA, state = _RPCState((), _common.EMPTY_METADATA, _common.EMPTY_METADATA,
grpc.StatusCode.INTERNAL, grpc.StatusCode.INTERNAL,
'Exception serializing request!') 'Exception serializing request!')
rendezvous = _Rendezvous(state, None, None, deadline) rendezvous = _Rendezvous(state, None, None, deadline)

@ -37,7 +37,7 @@ import six
import grpc import grpc
from grpc._cython import cygrpc from grpc._cython import cygrpc
_EMPTY_METADATA = cygrpc.Metadata(()) EMPTY_METADATA = cygrpc.Metadata(())
CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY = { CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY = {
cygrpc.ConnectivityState.idle: cygrpc.ConnectivityState.idle:
@ -107,7 +107,7 @@ def channel_args(options):
def cygrpc_metadata(application_metadata): def cygrpc_metadata(application_metadata):
return _EMPTY_METADATA if application_metadata is None else cygrpc.Metadata( return EMPTY_METADATA if application_metadata is None else cygrpc.Metadata(
cygrpc.Metadatum(encode(key), encode(value)) cygrpc.Metadatum(encode(key), encode(value))
for key, value in application_metadata) for key, value in application_metadata)

@ -57,7 +57,6 @@ _CLOSED = 'closed'
_CANCELLED = 'cancelled' _CANCELLED = 'cancelled'
_EMPTY_FLAGS = 0 _EMPTY_FLAGS = 0
_EMPTY_METADATA = cygrpc.Metadata(())
_UNEXPECTED_EXIT_SERVER_GRACE = 1.0 _UNEXPECTED_EXIT_SERVER_GRACE = 1.0
@ -143,7 +142,7 @@ def _abort(state, call, code, details):
effective_details = details if state.details is None else state.details effective_details = details if state.details is None else state.details
if state.initial_metadata_allowed: if state.initial_metadata_allowed:
operations = (cygrpc.operation_send_initial_metadata( operations = (cygrpc.operation_send_initial_metadata(
_EMPTY_METADATA, _EMPTY_FLAGS), _common.EMPTY_METADATA, _EMPTY_FLAGS),
cygrpc.operation_send_status_from_server( cygrpc.operation_send_status_from_server(
_common.cygrpc_metadata(state.trailing_metadata), _common.cygrpc_metadata(state.trailing_metadata),
effective_code, effective_details, _EMPTY_FLAGS),) effective_code, effective_details, _EMPTY_FLAGS),)
@ -416,7 +415,7 @@ def _send_response(rpc_event, state, serialized_response):
else: else:
if state.initial_metadata_allowed: if state.initial_metadata_allowed:
operations = (cygrpc.operation_send_initial_metadata( operations = (cygrpc.operation_send_initial_metadata(
_EMPTY_METADATA, _EMPTY_FLAGS), _common.EMPTY_METADATA, _EMPTY_FLAGS),
cygrpc.operation_send_message(serialized_response, cygrpc.operation_send_message(serialized_response,
_EMPTY_FLAGS),) _EMPTY_FLAGS),)
state.initial_metadata_allowed = False state.initial_metadata_allowed = False
@ -446,8 +445,8 @@ def _status(rpc_event, state, serialized_response):
] ]
if state.initial_metadata_allowed: if state.initial_metadata_allowed:
operations.append( operations.append(
cygrpc.operation_send_initial_metadata(_EMPTY_METADATA, cygrpc.operation_send_initial_metadata(
_EMPTY_FLAGS)) _common.EMPTY_METADATA, _EMPTY_FLAGS))
if serialized_response is not None: if serialized_response is not None:
operations.append( operations.append(
cygrpc.operation_send_message(serialized_response, cygrpc.operation_send_message(serialized_response,
@ -549,12 +548,12 @@ def _find_method_handler(rpc_event, generic_handlers):
def _handle_unrecognized_method(rpc_event): def _handle_unrecognized_method(rpc_event):
operations = ( operations = (cygrpc.operation_send_initial_metadata(_common.EMPTY_METADATA,
cygrpc.operation_send_initial_metadata(_EMPTY_METADATA, _EMPTY_FLAGS), _EMPTY_FLAGS),
cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS), cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
cygrpc.operation_send_status_from_server( cygrpc.operation_send_status_from_server(
_EMPTY_METADATA, cygrpc.StatusCode.unimplemented, _common.EMPTY_METADATA, cygrpc.StatusCode.unimplemented,
b'Method not found!', _EMPTY_FLAGS),) b'Method not found!', _EMPTY_FLAGS),)
rpc_state = _RPCState() rpc_state = _RPCState()
rpc_event.operation_call.start_server_batch( rpc_event.operation_call.start_server_batch(
operations, lambda ignored_event: (rpc_state, (),)) operations, lambda ignored_event: (rpc_state, (),))

Loading…
Cancel
Save