From ab439617f3f5c769af3e124912b96aab3a5b0188 Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Thu, 15 Apr 2021 19:54:48 +0300 Subject: [PATCH] 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