From 512fab735a911f2764df9fd8fdc4857e59dd50db Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Thu, 15 Apr 2021 19:45:59 +0300 Subject: [PATCH 1/2] Fix remaining flake8 errors --- conftest.py | 2 +- jmbase/jmbase/twisted_utils.py | 2 +- jmdaemon/jmdaemon/daemon_protocol.py | 4 ++-- scripts/snicker/snicker-finder.py | 1 + scripts/snicker/snicker-recovery.py | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index 011115e..94c57b7 100644 --- a/conftest.py +++ b/conftest.py @@ -17,7 +17,7 @@ def get_bitcoind_version(version_string): # this utility function returns the version number # as a tuple in the form (major, minor, patch) version_tuple = re.match( - b'.*v(?P\d+)\.(?P\d+)\.(?P\d+)', + br'.*v(?P\d+)\.(?P\d+)\.(?P\d+)', version_string).groups() return tuple(map(lambda x: int(x), version_tuple)) diff --git a/jmbase/jmbase/twisted_utils.py b/jmbase/jmbase/twisted_utils.py index fc6798c..f85a1ad 100644 --- a/jmbase/jmbase/twisted_utils.py +++ b/jmbase/jmbase/twisted_utils.py @@ -2,7 +2,7 @@ from zope.interface import implementer from twisted.internet.error import ReactorNotRunning from twisted.internet import reactor, defer -from twisted.internet.endpoints import TCP4ClientEndpoint +from twisted.internet.endpoints import TCP4ClientEndpoint, UNIXClientEndpoint from twisted.web.client import Agent, BrowserLikePolicyForHTTPS import txtorcon from txtorcon.web import tor_agent diff --git a/jmdaemon/jmdaemon/daemon_protocol.py b/jmdaemon/jmdaemon/daemon_protocol.py index 2694e0b..954293c 100644 --- a/jmdaemon/jmdaemon/daemon_protocol.py +++ b/jmdaemon/jmdaemon/daemon_protocol.py @@ -415,8 +415,8 @@ class SNICKERDaemonServerProtocol(HTTPPassThrough): @SNICKERReceiverGetProposals.responder def on_SNICKER_RECEIVER_GET_PROPOSALS(self): - for server in self.servers: - self.getRequest(server, self.receive_proposals_from_server) + for srv in self.servers: + self.getRequest(srv, self.receive_proposals_from_server) return {'accepted': True} def receive_proposals_from_server(self, response, server): diff --git a/scripts/snicker/snicker-finder.py b/scripts/snicker/snicker-finder.py index e49e31c..470a54f 100644 --- a/scripts/snicker/snicker-finder.py +++ b/scripts/snicker/snicker-finder.py @@ -24,6 +24,7 @@ in Bitcoin Core in order to get full transactions, since it parses the raw blocks. """ +import sys from optparse import OptionParser from jmbase import bintohex, EXIT_ARGERROR, jmprint import jmbitcoin as btc diff --git a/scripts/snicker/snicker-recovery.py b/scripts/snicker/snicker-recovery.py index 1fa6b85..c72739c 100644 --- a/scripts/snicker/snicker-recovery.py +++ b/scripts/snicker/snicker-recovery.py @@ -24,6 +24,7 @@ keys, so as a reminder, *always* back up either jmdat wallet files, or at least, the imported keys themselves.) """ +import sys from optparse import OptionParser from jmbase import bintohex, EXIT_ARGERROR, jmprint import jmbitcoin as btc From ab439617f3f5c769af3e124912b96aab3a5b0188 Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Thu, 15 Apr 2021 19:54:48 +0300 Subject: [PATCH 2/2] Add flake8 linter script --- test/lint/lint-python.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 test/lint/lint-python.sh diff --git a/test/lint/lint-python.sh b/test/lint/lint-python.sh new file mode 100755 index 0000000..66e09f1 --- /dev/null +++ b/test/lint/lint-python.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Based on Bitcoin Core's test/lint/lint-python.sh + +if ! command -v flake8 > /dev/null; then + echo "Skipping Python linting since flake8 is not installed." + exit 0 +elif flake8 --version | grep -q "Python 2"; then + echo "Skipping Python linting since flake8 is running under Python 2. Install the Python 3 version of flake8." + exit 0 +fi + +if [[ $# == 0 ]]; then + flake8 $(git ls-files "*.py") +else + flake8 "$@" +fi