format-code: enable flake8 instead of pycodestyle
flake8 is a more complete python linter than pycodestyle
as it contains pycodestyle, pyflakes and mccabe. I have
contributed fixes to all repositories so that flake8 passes,
so switch from pycodestyle to flake8 and enable everywhere.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I93867773830d476809364f44ad78104241d66a2a
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index 1a957d4..fff4b25 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -848,12 +848,12 @@
dockerfile_base += """
RUN pip3 install codespell
+RUN pip3 install flake8
RUN pip3 install gitlint
RUN pip3 install inflection
RUN pip3 install jsonschema
RUN pip3 install meson==0.63.0
RUN pip3 install protobuf
-RUN pip3 install pycodestyle
RUN pip3 install requests
"""
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index c988ea8..53b8f12 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -29,7 +29,7 @@
commit_spelling \
clang_format \
eslint \
- pycodestyle \
+ flake8 \
shellcheck \
)
LINTERS_DISABLED=()
@@ -167,11 +167,13 @@
--no-error-on-unmatched-pattern "$@"
}
-LINTER_REQUIRE+=([pycodestyle]="pycodestyle;setup.cfg")
-LINTER_TYPES+=([pycodestyle]="python")
-function do_pycodestyle() {
- pycodestyle --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E203,E501 \
- --show-source "$@"
+LINTER_REQUIRE+=([flake8]="flake8")
+LINTER_IGNORE+=([flake8]=".flake8-ignore")
+LINTER_TYPES+=([flake8]="python")
+function do_flake8() {
+ flake8 --show-source --extend-ignore=E203,E501 "$@"
+ # We disable E203 and E501 because 'black' is handling these and they
+ # disagree on best practices.
}
LINTER_REQUIRE+=([shellcheck]="shellcheck;.shellcheck")