From 756d96fcfd3cc7d329f05a9f64680dcc78fb80a8 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 11 Mar 2024 18:56:51 +0100 Subject: [PATCH 1/5] chore: drop unused arguments to string.format() Signed-off-by: Pino Toscano --- src/insights_client/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/insights_client/__init__.py b/src/insights_client/__init__.py index 16d2ab19..49d359b9 100644 --- a/src/insights_client/__init__.py +++ b/src/insights_client/__init__.py @@ -241,15 +241,13 @@ def run_phase(phase, client, validated_eggs): stdout, stderr = process.communicate() if process.returncode == 0: # phase successful, don't try another egg - client_debug( - "phase '{phase}' successful".format(egg=egg, phase=phase["name"]) - ) + client_debug("phase '{phase}' successful".format(phase=phase["name"])) update_motd_message() return client_debug( "phase '{phase}' failed with return code {rc}".format( - egg=egg, phase=phase["name"], rc=process.returncode + phase=phase["name"], rc=process.returncode ) ) if process.returncode == 1: From 21ab7415a52c85b58ff64d1f9d08c623d52f526c Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 13 Mar 2024 12:49:17 +0100 Subject: [PATCH 2/5] chore: drop unused import Signed-off-by: Pino Toscano --- integration-tests/test_registration.py | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/test_registration.py b/integration-tests/test_registration.py index ec47be2b..e9218ab1 100644 --- a/integration-tests/test_registration.py +++ b/integration-tests/test_registration.py @@ -1,5 +1,4 @@ import os -import subprocess import pytest From c18bd92d49e243b6444728b645d666466cd23a47 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 12 Mar 2024 19:42:04 +0100 Subject: [PATCH 3/5] chore: fix/improve flake8 configuration Fix & improve a bit the configuration for flake8, so it can be run without issues: - drop all the old ignores, no more needed (all the issues where fixed) - drop the excludes for paths that are either do not exist anymore, or that it is not a problem to scan (e.g. "docs") - add the explicit filename patterns so "*.py.in" files are scanned too; adding ".py" is needed since "filename" replaces the default paths - set the same line length as used by black - add a couple of known ignores related to the style formatted by black - ignore longer lines in a couple of files; they are there already, and fixing them can be done gradually - exclude also the default meson build directory Signed-off-by: Pino Toscano --- .flake8 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 2f0db80e..c18df017 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,19 @@ [flake8] -ignore = E501,E126,E127,E128,E722 -exclude = bin,docs,include,lib,lib64,.git +filename = + *.py, + *.py.in, +# same limit as black +max-line-length = 88 +ignore = + # E203 whitespace before ':' + # result of black-formatted code + E203, + # W503: line break before binary operator + W503 +per-file-ignores = + # some lines are longer than 88 + src/insights_client/__init__.py: E501 + integration-tests/test_unregister.py: E501 +extend-exclude = + # default build directory + build/, From 7624555a0036b9531e003a1f6f7853bcda3ab0e6 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 12 Mar 2024 19:47:20 +0100 Subject: [PATCH 4/5] ci: extend stylish workflow with flake8 check In addition to the format with black, check the sources also using flake8. The job will install flake8 as available in the latest stable Fedora version. Use a marketplace action to annotate the files with the result of the flake8 run. Signed-off-by: Pino Toscano --- .github/workflows/stylish.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stylish.yml b/.github/workflows/stylish.yml index 4d407df3..6b2ccdf9 100644 --- a/.github/workflows/stylish.yml +++ b/.github/workflows/stylish.yml @@ -6,7 +6,7 @@ on: jobs: stylish: - name: "black" + name: "black & flake8" runs-on: ubuntu-latest container: image: fedora:latest @@ -16,6 +16,7 @@ jobs: run: | dnf --setopt install_weak_deps=False install -y \ git-core \ + python3-flake8 \ python3-pip - uses: actions/checkout@v4 @@ -23,3 +24,10 @@ jobs: - uses: psf/black@stable with: version: "24.2.0" + + - name: Setup flake8 annotations + uses: rbialon/flake8-annotations@v1 + + - name: Run flake8 + run: | + flake8 From a3fef3b4f2560e5407399546b6f4b6017dc2b296 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 13 Mar 2024 07:14:24 +0100 Subject: [PATCH 5/5] chore: add flake8 to development requirements Signed-off-by: Pino Toscano --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 4f670985..e27c1cf8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ # the version of black is specified also in the stylish.yml github workflow; # please update the version there in case it is bumped here black==24.2.0 +flake8