From ba4bbd4129386974abfbeea344ba5314c4b3bce2 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Sun, 1 Aug 2021 17:55:08 +0300 Subject: [PATCH] Lint fixes: - split the last long line in the connection module - resolved pylint useless-object-inheritance and unused-variable --- minode/connection.py | 3 ++- minode/message.py | 16 ++++++++-------- minode/structure.py | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/minode/connection.py b/minode/connection.py index 6da24f8..afefbb0 100644 --- a/minode/connection.py +++ b/minode/connection.py @@ -260,7 +260,8 @@ class Connection(threading.Thread): while len(to_send) > 0: if len(to_send) > 10000: # We limit size of inv messaged to 10000 entries - # because they might time out in very slow networks (I2P) + # because they might time out + # in very slow networks (I2P) pack = random.sample(to_send, 10000) self.send_queue.put(message.Inv(pack)) to_send.difference_update(pack) diff --git a/minode/message.py b/minode/message.py index 1afab2b..a56ca40 100644 --- a/minode/message.py +++ b/minode/message.py @@ -7,7 +7,7 @@ import time from . import shared, structure -class Header(object): +class Header(): def __init__(self, command, payload_length, payload_checksum): self.command = command self.payload_length = payload_length @@ -42,7 +42,7 @@ class Header(object): return cls(command, payload_length, payload_checksum) -class Message(object): +class Message(): def __init__(self, command, payload): self.command = command self.payload = payload @@ -84,7 +84,7 @@ class Message(object): return cls(h.command, payload) -class Version(object): +class Version(): def __init__( self, host, port, protocol_version=shared.protocol_version, services=shared.services, nonce=shared.nonce, @@ -127,8 +127,8 @@ class Version(object): payload = m.payload - ( # unused: net_addr_local - protocol_version, services, t, net_addr_remote, _, nonce + ( # unused: timestamp, net_addr_local + protocol_version, services, _, net_addr_remote, _, nonce ) = struct.unpack('>IQQ26s26s8s', payload[:80]) net_addr_remote = structure.NetAddrNoPrefix.from_bytes(net_addr_remote) @@ -154,7 +154,7 @@ class Version(object): return cls(host, port, protocol_version, services, nonce, user_agent) -class Inv(object): +class Inv(): def __init__(self, vectors): self.vectors = set(vectors) @@ -189,7 +189,7 @@ class Inv(object): return cls(vectors) -class GetData(object): +class GetData(): def __init__(self, vectors): self.vectors = set(vectors) @@ -224,7 +224,7 @@ class GetData(object): return cls(vectors) -class Addr(object): +class Addr(): def __init__(self, addresses): self.addresses = addresses diff --git a/minode/structure.py b/minode/structure.py index 106a7c0..027009c 100644 --- a/minode/structure.py +++ b/minode/structure.py @@ -9,7 +9,7 @@ import time from . import shared -class VarInt(object): +class VarInt(): def __init__(self, n): self.n = n @@ -43,7 +43,7 @@ class VarInt(object): return cls(n) -class Object(object): +class Object(): def __init__( self, nonce, expires_time, object_type, version, stream_number, object_payload @@ -138,7 +138,7 @@ class Object(object): return hashlib.sha512(self.to_bytes()[8:]).digest() -class NetAddrNoPrefix(object): +class NetAddrNoPrefix(): def __init__(self, services, host, port): self.services = services self.host = host @@ -170,7 +170,7 @@ class NetAddrNoPrefix(object): return cls(services, host, port) -class NetAddr(object): +class NetAddr(): def __init__(self, services, host, port, stream=shared.stream): self.stream = stream self.services = services