From 31b1a383f0be154fe03a19c1beec931679a3008c Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Tue, 2 Aug 2022 23:34:48 +0200 Subject: [PATCH] tools/koji-compose.py: test with pylint and fix found issues Check `tools/koji-compose.py` using pylint as part of GitHub actions. Fix all issues that were found by pylint. --- .github/workflows/tests.yml | 4 ++-- tools/koji-compose.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a0cbc1256..8a856b25c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -88,7 +88,7 @@ jobs: steps: - name: Install build and test dependencies - run: dnf -y install python3-pylint git-core + run: dnf -y install python3-pylint git-core python3-requests - name: Check out code into the Go module directory uses: actions/checkout@v3 @@ -97,7 +97,7 @@ jobs: - name: Analysing the code with pylint run: | - python3 -m pylint dnf-json + python3 -m pylint dnf-json tools/koji-compose.py lint: name: "⌨ Lint" diff --git a/tools/koji-compose.py b/tools/koji-compose.py index 59d40f77e..c61f0c27d 100755 --- a/tools/koji-compose.py +++ b/tools/koji-compose.py @@ -1,4 +1,6 @@ #!/usr/bin/python3 +# pylint: disable=invalid-name + import argparse import json import sys @@ -200,15 +202,18 @@ def main(): sys.exit(1) status = r.json()["status"] print(status, file=sys.stderr) + if status == "success": print("Compose worked!", file=sys.stderr) print(r.text, file=sys.stderr) break - elif status == "failure": + + if status == "failure": print("compose failed!", file=sys.stderr) print(r.text, file=sys.stderr) sys.exit(1) - elif status != "pending" and status != "running": + + if status not in ("pending", "running"): print(f"unexpected status: {status}", file=sys.stderr) print(r.text, file=sys.stderr) sys.exit(1) @@ -218,7 +223,7 @@ def main(): r = composer_api_client.compose_log(compose_id) logs = r.json() assert "image_builds" in logs - assert type(logs["image_builds"]) == list + assert isinstance(logs["image_builds"], list) assert len(logs["image_builds"]) == len(cr["image_requests"])