From patchwork Fri Aug 30 12:52:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21080 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 45CD2C32C2 for ; Fri, 30 Aug 2024 12:53:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C36A9634A6; Fri, 30 Aug 2024 14:53:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WzongnjJ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A8C116341E for ; Fri, 30 Aug 2024 14:53:22 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:cdac:b850:c793:ea45]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1A867227; Fri, 30 Aug 2024 14:52:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1725022333; bh=pcQZTivq0JBKn9uoUS3oM5Kz0vJmUBmw3oxGp7TlPi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WzongnjJixxOhZNB2b3hbwOMpqzJv+DorqOxMBIzKUxYiDgZkPrd0st9gM8PrUCQA tMG+HnrL9w2Pekq5E8kL5TEKUHRp9fdP69EB3KE7Ig+T0d1WcJ8VixVj/OqGuqMDV0 eHCowdhYYUrIKZBBB1oBNOatw8PMpv0CvlJZckE0= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 1/3] utils: checkstyle: Remove leading colon from pycodestyle messages Date: Fri, 30 Aug 2024 14:52:58 +0200 Message-ID: <20240830125311.1702053-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830125311.1702053-1-stefan.klug@ideasonboard.com> References: <20240830125311.1702053-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The pycodestyle messages contain a leading ': ' which is not nice to look at. Ignore it. Signed-off-by: Stefan Klug Reviewed-by: Laurent Pinchart --- utils/checkstyle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index c9e41d4149f7..c6016f60a446 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -711,7 +711,7 @@ class MesonChecker(StyleChecker): class Pep8Checker(StyleChecker): patterns = ('*.py',) - results_regex = re.compile(r'stdin:([0-9]+):([0-9]+)(.*)') + results_regex = re.compile(r'stdin:([0-9]+):([0-9]+): (.*)') def __init__(self, content): super().__init__() From patchwork Fri Aug 30 12:52:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21081 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6D033C323E for ; Fri, 30 Aug 2024 12:53:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D62E6341E; Fri, 30 Aug 2024 14:53:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="c7ThQK/U"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 898A263466 for ; Fri, 30 Aug 2024 14:53:25 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:cdac:b850:c793:ea45]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 58FBF512; Fri, 30 Aug 2024 14:52:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1725022336; bh=Uap09w+3CURzA5gEtOe1Er5VKL6HcqpeE57robYcvCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c7ThQK/UeO/GHlCuS1zemkYW9X6to71IRgMvoy6dYeuVFSBU5SngIsaVkhztFvy2A MFC/0E8SoawqdTY2hFX+fk7Ox2GeAfgdon+xkAEpKJVnANeioz+PmSXXfmnhcxK1D8 Gmq9gfsXMeiKEfp79gUO/to27Nk+ix6F8oi+uA+s= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 2/3] utils: checkstye: Show issue position for python issues Date: Fri, 30 Aug 2024 14:52:59 +0200 Message-ID: <20240830125311.1702053-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830125311.1702053-1-stefan.klug@ideasonboard.com> References: <20240830125311.1702053-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" pycodestyle doesn't report the issue length. But it reports the position. Use that as indicator with zero length. This is better than no indicator at all and reduces confusion when multiple issues occur on the same line. Signed-off-by: Stefan Klug Reviewed-by: Laurent Pinchart --- utils/checkstyle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index c6016f60a446..5901f1a71562 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -737,7 +737,7 @@ class Pep8Checker(StyleChecker): if line_number in line_numbers: line = self.__content[line_number - 1] - issues.append(StyleIssue(line_number, None, line, msg)) + issues.append(StyleIssue(line_number, [position, position + 1], line, msg)) return issues From patchwork Fri Aug 30 12:53:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21082 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DAAE7C32C2 for ; Fri, 30 Aug 2024 12:53:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A580634CB; Fri, 30 Aug 2024 14:53:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OxpwADAi"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3666D634CD for ; Fri, 30 Aug 2024 14:53:28 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:cdac:b850:c793:ea45]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2CDDA227; Fri, 30 Aug 2024 14:52:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1725022339; bh=5DyUirRWXcKgZ9sFV/gFzJ9MFHuB7wY4kgwZ3tjYRrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxpwADAint9ON1C7L/NhSch8BSjCTcY60K516N4WD4uX3non42pbG7dSpD0XXelGh Ye0CeV54PBRsnj+fQB7N78vwFdyw4BV2A3znApBFnO6xlVOOoTen0JnpcdWGZNki4Q u8f4TcmU50T2O2wevYclGMSyEW1B8OJYc9Vh9UfE= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 3/3] utils: checkstyle: Add a python formatter Date: Fri, 30 Aug 2024 14:53:00 +0200 Message-ID: <20240830125311.1702053-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830125311.1702053-1-stefan.klug@ideasonboard.com> References: <20240830125311.1702053-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Reporting style issues on python files is great, automatically fixing them is even better. Add a call to autopep8 for python files. Signed-off-by: Stefan Klug --- utils/checkstyle.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 5901f1a71562..ed15145b64a4 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -954,6 +954,21 @@ class StripTrailingSpaceFormatter(Formatter): return ''.join(lines) +class Pep8Formatter(Formatter): + patterns = ('*.py',) + + @classmethod + def format(cls, filename, data): + try: + ret = subprocess.run(['autopep8', '--ignore=E501', '-'], + input=data.encode('utf-8'), stdout=subprocess.PIPE) + except FileNotFoundError: + issues.append(StyleIssue(0, None, None, 'Please install autopep8 to format python additions')) + return issues + + return ret.stdout.decode('utf-8') + + # ------------------------------------------------------------------------------ # Style checking #