From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iAEg7/2Z; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id CF6CB5A026F for ; Wed, 01 Oct 2025 12:23:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759314237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0RF56J8j+LBQNmAcHdyPHEXYInKYoRWKs/YVFP43XQU=; b=iAEg7/2Z1Af1RYd7/u8bAdaQbggLoMIy+G2UoabBHTb0ymxpQRfFMIlCF6MlKbIrUEs1tI oIak84kWZScWFb1jY89VfyvM0Jg/3djFLKFPWTFmQ8N7AFZ4Jb7R9IGjim+nz2gLoSlcMw bErrYeR6uVq0XJVa2oP9LaIKH7zEHQc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-mfED71c1Mw25kPWGTZSqJA-1; Wed, 01 Oct 2025 06:23:56 -0400 X-MC-Unique: mfED71c1Mw25kPWGTZSqJA-1 X-Mimecast-MFC-AGG-ID: mfED71c1Mw25kPWGTZSqJA_1759314235 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e407c600eso30733935e9.3 for ; Wed, 01 Oct 2025 03:23:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759314234; x=1759919034; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0RF56J8j+LBQNmAcHdyPHEXYInKYoRWKs/YVFP43XQU=; b=hK0KXi5vPcOjmyjox30ojuorNPdiPZ43CX3lxxNUSuUZPEqIDsLIzgpuZi/c7bmFJh ykjxstOubtuUMY75OZGCJXi784g5RHaD+7qa+f4Q4OoRaHOewmYxelLbK33D+59xbLRf kYz6886UiK9dBC1peSZVix4nIE6qeNRoDFYYrXKI+Rrq3EtSBEtSH0AC8mQhoch0l6LC ESNgMC61jfHMmcbnZIOeSZZulU4NiHFUvvNRx+75qJl8HMfSn5/1fOppXfugLFc9LFR6 xabOy8iCcqcXTxmOL9LQ+xUF206ZTgq88FMX0rGwPQK1BXNynMB0ZN1LeVaTVe8P3vWP C+8A== X-Gm-Message-State: AOJu0YxbbjRHAEOvRxAj/9Q53Qz5CknhiCiqAWKj+PEn6kENzqV4OG8X +86KglkLZ1a566ACMr7cTKO0XP2Q4tUSiu07xM3IMTMM+ZOBOOE5zMvbGhYLlsjW6RplCYIO0nP PiyWsOJxpZZ316TM93kMOqJN4al6xo+QBje+Ev7nsaCDASQLGIUVZXatM6kaxxg== X-Gm-Gg: ASbGncs733EzdTO1gIHm7JL4AjuzrRk33RmSvmF5et8dsQRl/wMhBp3wS3lezg68eEk 91ILDKZRX+ECCJUN7DFGQxk/AozH/OPsBW7a+xwzRTx1RZho4zRvL/ESNoOjizH04a/8Mcwn8Jd 0NJZjPnT4M7p3Fr6JO1kda7/fgTaT2Z9+b8F30MWStNmNgFvNPKzCmbQDbfXqsn3zamLuS+fPc0 oORQamgzxnxUTK6jJNlW+J79cbdXX1fmeVKIReXJUgSoyIMlK3LwNo7jiC7Su8s6ALECELERCyH 9A1RmlDUCpQ9jOT1Kd8hLHWUfaCmlgNvIO3pdmaFognFxC79VQuYWOpG X-Received: by 2002:a05:600c:6094:b0:46e:4340:adf7 with SMTP id 5b1f17b1804b1-46e6125d5dfmr25639885e9.8.1759314234345; Wed, 01 Oct 2025 03:23:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcwuGIxEeIbvQdUKmc5HSiJaYQu4x85C1NzyWvP8IczZR1S33sRE6S+ZYapcx1ha05wuOt+Q== X-Received: by 2002:a05:600c:6094:b0:46e:4340:adf7 with SMTP id 5b1f17b1804b1-46e6125d5dfmr25639495e9.8.1759314233645; Wed, 01 Oct 2025 03:23:53 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a020a3sm33212625e9.10.2025.10.01.03.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Oct 2025 03:23:52 -0700 (PDT) Date: Wed, 1 Oct 2025 12:23:51 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/6] test: Add linting of Python test scripts Message-ID: <20251001122351.7020b79a@elisabeth> In-Reply-To: <20251001095202.3875003-3-david@gibson.dropbear.id.au> References: <20251001095202.3875003-1-david@gibson.dropbear.id.au> <20251001095202.3875003-3-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 0App33W8Kenwcoy0sBWhGsTcXonkTQmsJPIo3jyLzT4_1759314235 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: TMZN7L5JB4NQYVPZLYFDJEXPMLD54QTW X-Message-ID-Hash: TMZN7L5JB4NQYVPZLYFDJEXPMLD54QTW X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 1 Oct 2025 19:51:58 +1000 David Gibson wrote: > We currently have one test moved to the new exeter based framwork written > in Python. We plan to add many more, so add linting (flake8) and type > checking (mypy) of those scripts. This can be invoked manually with > "make flake8" or "make mypy" in test/, and is also added to the static > checkers test set. I never used a Python linter, so I'm not sure if it's as bad as Go or Rust linters taking the whole poetry away, as it happened for instance in my most recent experience with 'cargo fmt': https://github.com/AsahiLinux/muvm/compare/68094c02c19b6f5d5e3def6d29379c1244c9a5e4..9af11c334a1ce37f533c056d982f8608c8d80d27#diff-e1a95ce380b9a8a317f97cccce1cbfd3dccd343dc62169ed1340208ab304fab9L106 https://github.com/AsahiLinux/muvm/pull/111#discussion_r1863551727 (you need to click around before you get to it, no idea how to share a proper link that opens that comment right away) Maybe with Python it's not as annoying? I don't have a strong preference against this, I just wanted to raise a possible downside. In general, my thought is that coding style serves a purpose, and it's used by humans for humans, so it's flexible, with exceptions, and reasons behind it and behind those exceptions. If we just pass everything through a linter, well, except for the purposes of revision control, we don't really need a coding style? > Signed-off-by: David Gibson > --- > test/Makefile | 14 +++++++++++++- > test/build/build.py | 5 +++-- > test/build/static_checkers.sh | 6 +++++- > 3 files changed, 21 insertions(+), 4 deletions(-) > > diff --git a/test/Makefile b/test/Makefile > index 69987d0b..2637e0ed 100644 > --- a/test/Makefile > +++ b/test/Makefile > @@ -8,6 +8,8 @@ > BATS = bats -j $(shell nproc) > EXETOOL = exeter/exetool/exetool > WGET = wget -c > +FLAKE8 = flake8 > +MYPY = mypy --strict > > DEBIAN_IMGS = debian-8.11.0-openstack-amd64.qcow2 \ > debian-10-nocloud-amd64.qcow2 \ > @@ -65,11 +67,15 @@ LOCAL_ASSETS = mbuto.img mbuto.mem.img podman/bin/podman QEMU_EFI.fd \ > ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS) > > EXETER_PYPATH = exeter/py3 > +EXETER_PYTHON = build/build.py > EXETER_BATS = smoke/smoke.sh.bats \ > - build/build.py.bats build/static_checkers.sh.bats > + $(EXETER_PYTHON:%=%.bats) build/static_checkers.sh.bats > BATS_FILES = $(EXETER_BATS) \ > podman/test/system/505-networking-pasta.bats > > +# Python test code (for linters) > +PYPKGS = $(EXETER_PYTHON) > + > CFLAGS = -Wall -Werror -Wextra -pedantic -std=c99 > > assets: $(ASSETS) > @@ -130,6 +136,12 @@ medium.bin: > big.bin: > dd if=/dev/urandom bs=1M count=10 of=$@ > > +flake8: pull-exeter > + PYTHONPATH=$(EXETER_PYPATH) $(FLAKE8) $(PYPKGS) > + > +mypy: pull-exeter > + PYTHONPATH=$(EXETER_PYPATH) $(MYPY) $(PYPKGS) > + > $(EXETER_BATS): %.bats: % $(EXETOOL) > PYTHONPATH=$(EXETER_PYPATH) $(EXETOOL) bats -- $< > $@ > > diff --git a/test/build/build.py b/test/build/build.py > index e49287c9..e3de8305 100755 > --- a/test/build/build.py > +++ b/test/build/build.py > @@ -18,11 +18,12 @@ import os > from pathlib import Path > import subprocess > import tempfile > -from typing import Iterable, Iterator > +from typing import Iterator > > import exeter > > -def sh(cmd): > + > +def sh(cmd: str) -> None: > """Run given command in a shell""" > subprocess.run(cmd, shell=True) > > diff --git a/test/build/static_checkers.sh b/test/build/static_checkers.sh > index 42806e79..228b99ae 100755 > --- a/test/build/static_checkers.sh > +++ b/test/build/static_checkers.sh > @@ -21,6 +21,10 @@ exeter_set_description cppcheck "passt sources pass cppcheck" > exeter_register clang_tidy make -C .. clang-tidy > exeter_set_description clang_tidy "passt sources pass clang-tidy" > > -exeter_main "$@" > +exeter_register flake8 make flake8 > +exeter_set_description flake8 "passt tests in Python pass flake8" > > +exeter_register mypy make mypy > +exeter_set_description mypy "passt tests in Python pass mypy --strict" > > +exeter_main "$@" -- Stefano