Skip to content

Commit

Permalink
Clean up some artefacts reported by pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Booth committed Jan 1, 2019
1 parent 8550d67 commit d8568f6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
16 changes: 6 additions & 10 deletions aiorpcx/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
from functools import partial
from numbers import Number

import attr
from aiorpcx import Queue, Event, CancelledError
from aiorpcx import Event, CancelledError
from aiorpcx.util import signature_info


Expand All @@ -62,7 +61,7 @@ def __eq__(self, other):


class Request(SingleRequest):
def send_result(self, response):
def send_result(self, _response):
return None


Expand Down Expand Up @@ -105,9 +104,7 @@ def __init__(self, result):


class CodeMessageError(Exception):

def __init__(self, code, message):
super().__init__(code, message)
'''Invoke as CodeMessageError(code, message)'''

@property
def code(self):
Expand Down Expand Up @@ -184,7 +181,6 @@ def _message_id(cls, message, require_id):
def _validate_message(cls, message):
'''Validate other parts of the message other than those
done in _message_id.'''
pass

@classmethod
def _request_args(cls, request):
Expand Down Expand Up @@ -612,7 +608,7 @@ def _receive_response(self, result, request_id):
else:
message = f'response to unsent request (ID: {request_id})'
raise ProtocolError.invalid_request(message) from None
request, event = self._requests.pop(request_id)
_request, event = self._requests.pop(request_id)
event.result = result
event.set()
return []
Expand Down Expand Up @@ -664,7 +660,7 @@ def _receive_response_batch(self, payloads):
ordered_ids, ordered_results = zip(*ordered)
if ordered_ids not in self._requests:
raise ProtocolError.invalid_request('response to unsent batch')
request_batch, event = self._requests.pop(ordered_ids)
_request_batch, event = self._requests.pop(ordered_ids)
event.result = ordered_results
event.set()
return []
Expand Down Expand Up @@ -745,7 +741,7 @@ def receive_message(self, message):
def cancel_pending_requests(self):
'''Cancel all pending requests.'''
exception = CancelledError()
for request, event in self._requests.values():
for _request, event in self._requests.values():
event.result = exception
event.set()
self._requests.clear()
Expand Down
20 changes: 17 additions & 3 deletions aiorpcx/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@
import time
from contextlib import suppress

from aiorpcx import *
from aiorpcx.curio import (
Event, TaskGroup, TaskTimeout, CancelledError,
timeout_after, spawn_sync, ignore_after
)
from aiorpcx.framing import (
NewlineFramer, BitcoinFramer,
BadMagicError, BadChecksumError, OversizedPayloadError
)
from aiorpcx.jsonrpc import (
Request, Batch, Notification, ProtocolError, RPCError,
JSONRPC, JSONRPCv2, JSONRPCConnection
)
from aiorpcx.util import Concurrency


Expand All @@ -55,7 +66,7 @@ async def create_connection(self):
self.session_factory, self.host, self.port, **self.kwargs)

async def __aenter__(self):
transport, self.protocol = await self.create_connection()
_transport, self.protocol = await self.create_connection()
# By default, do not limit outgoing connections
self.protocol.bw_limit = 0
return self.protocol
Expand Down Expand Up @@ -136,6 +147,9 @@ def _using_bandwidth(self, size):
'''Called when sending or receiving size bytes.'''
self.bw_charge += size

def _receive_messages(self):
raise NotImplementedError

async def _process_messages(self):
'''Process incoming messages asynchronously and consume the
results.
Expand Down Expand Up @@ -343,7 +357,6 @@ def default_framer(self):

async def handle_message(self, message):
'''message is a (command, payload) pair.'''
pass

async def send_message(self, message):
'''Send a message (command, payload) over the network.'''
Expand All @@ -353,6 +366,7 @@ async def send_message(self, message):
class BatchError(Exception):

def __init__(self, request):
super().__init__(request)
self.request = request # BatchRequest object


Expand Down
4 changes: 2 additions & 2 deletions aiorpcx/socks.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _authentication(self, auth):
raise SOCKSProtocolError(f'password has invalid length '
f'{len(pwd_bytes)}')
return b''.join([bytes([1, len(user_bytes)]), user_bytes,
bytes([len(pwd_bytes)]), pwd_bytes]), [0, 2]
bytes([len(pwd_bytes)]), pwd_bytes]), [0, 2]
return b'', [0]

def _start(self):
Expand Down Expand Up @@ -330,7 +330,7 @@ async def _connect(self, addresses):
Return an (open_socket, address) pair on success.
'''
assert len(addresses) > 0
assert addresses

exceptions = []
for address in addresses:
Expand Down

0 comments on commit d8568f6

Please sign in to comment.