From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795628000; b=Tt1kAwq7vVWeHts2PG/u/Sw+yte81MHBec+u0Xp7tokYae8w1qzNbK4YmCPNp9wFAoF9 2el0m+DMOtRpch/a/VBesMrvvtaJgwprCTQY/VqbkK8HiUyJtFOENjiYYUqCabcnoQgAS 2bNqS1qr2dWNXXh5hezh2SzrWztaQYAzgMP7R5v8N1T62HTLyPUTi1qPDyTHhav1sOpNr dJguT2TRenoyRb9UdlR/w4jy+RPGgnsAt0BNQ4ulc1IeYB5rmdgBufrUT9IpxnGtpD7cO ZbMfizlHtkonhpnPlsV3WabZiZ+evPAHrGOxGf/xPcQM3iAGGoGJh/4KnjSlH0VDwug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795628000; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=gEGLKKZSPIheBUE6mJYEzB53y8VIlfjMTA5tt2Toblk=; b=3eYrb4bedCPTv0s8OzSAKYzODYiHgi9W0VCHCjNRFnU1CObI2jWZNgxd+osdkdWH/Wh5 sw40JE+qcgtIGpU9vn8C+1kOY+q7O7NMIA4A7yJuIjgL0tcg+6Pi1FKy3GRDl54xxQHB/ 6kDt1/GJ93LFQ1iejxQYMU/zfUFntL5e4IsAe43IpBp/+uNR4LHMe4NTUjw5mBThYN1Vo wq4p8DsnXPsKaSsJqk+SjnhZmVgDtGgO3k9gDhjxBAGAtnmsw+rHQwTybz8U1VTfT8pwy dRi9ixJRIe4qY4SOw2Q1YDG0T/D6/2nvwVF6oCcrx53nMlHg/gJ1EiKLE0hIEIkqxeA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hOrPdtjo; arc=none smtp.remote-ip=209.85.215.170 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6266606A326 for ; Wed, 25 Nov 2026 17:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A6266606A326 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hOrPdtjo Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-cde0daf3a2aso2630196a12.3 for ; Wed, 25 Nov 2026 09:33:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795627999; x=1796232799; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=gEGLKKZSPIheBUE6mJYEzB53y8VIlfjMTA5tt2Toblk=; b=hOrPdtjouJxarub8kBrBIoW2ixC3AN/njO/f2iDeXguw9r2boPblVBlEUPoGXI0QTr TyFCewjYnk11EyZEhsQjglg9+gB68JBUyTxorjFF0n9sBFLeXy2rf7irj6xNnakIhfKo s7BWAgwGiAAGKbY4yRclsXSli3KleT/KubdVL+2za7iAUtOQ9Mk4NWFbbAJeaduumN4T rNcoyYpvGdaYhWFQLxW+724IxmT1drN1hxU+/y8YywNTEtHuWQHCrLNru+uRRc73Gl/+ QZSY8N9nG0qy10SG+WA73mWNFKUofqsB6VkWv8DiOGwiCwp/evuhQ7y0BzzyfI0Rto8l IS6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795627999; x=1796232799; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gEGLKKZSPIheBUE6mJYEzB53y8VIlfjMTA5tt2Toblk=; b=t/2Ilaeo95pnfgS9/zwp6hqRtnQwVE+4W3eiNC2JUBjTJjVTpT8OdELMDDZsw6Ajhg KT/ir9ImqS5niRoY/FDQwm7D7kB026GNr2bPESt+j3x7sQI9ewgbPTQMwSot165QDAzN z15CCFrzZVnZlfErgrkS56jgQ3wjJ9ZQbjDgC1rt9FVgV//rN1ZnNgQmn+nwIuOtk3hK EMRUQsKmYPnPm3WNs3MXRGWHpz2nZmlT44QiJ9b4NtBr/oZpyFxd3LkmX5HSaB7W+0rx RrOFA+xVSeNe/mImH9hgefsIMgG1AHYbAiZvKqgKS1wYwcXIgU4U89kFTgEhcZai15ol 12Nw== X-Forwarded-Encrypted: i=1; AL+hErFNWcB/h+WCLfjbkd17d/cvRFt9h3ciPVQHf9o3Y2CwM6qAs+Q7Lgf7h9rEJ48W+OrG1jC4irjBZhz+o4g=@vger.kernel.org X-Gm-Message-State: APuU4Z+RtLBhngo7u5a5H5Zy5PXrDJ5hy0z6uk1iPkJa3twJMbxeF8df IXg9GPSSAq7tMn2RjS7PJoPiELvJFeM3/9CqBc2+Csz6wiqyQqwKYc9K X-Gm-Gg: AZFdTZcgIeQDsaUZJ7TZbqq00NVIaV0v42ABaD/pZg26qe4+GYS3GWMBnUmd4AncHVM 6VuSsz0Qfjh+7tv+srQzmS1QU8LASW0qTdnWYaVO+752hQJrZy1VMI60CIzovf+YI5qroSUJpoS CaCFlxyeIAE9Tcs+t6wa/C2Tc6Ak1bEkpQdFfNEz4dliK3P2oV/MFTwJsiwFaf1GZ2pOjCsI0uZ VUc7jye1uAYzRdF0557A6rRVDK8zlMxtwj8XtIHwg+9Nknx60jGEjH7V/Ec9HNzyC/ciLctNNUd 0HWE+3ziiYqFWcFcAYMsCaxSpD19SsQBUg6DbfimHQX8M7P6sypv09BYtW3N+Hs/RvsH1/K1QIb rszHzNflJIQnoFc55vt0tYvrC8BEWjySgQqvIdvgOg/hLiCXWwmnfuWLM5H6z15WdkH0Wmqe7KP 05A/f5bbns3WmTQjeKYBDQcTQavhDzLl2BZgDbjA/9rLSSfTDqT8DEH270GVf8dKRyP7fMSVEbJ F/KXIV1s3jk39vAwvzgSuWxb2ZJE2DTwYrYjNUYwHvO/FcdAOvHdH8PsGHsO/zWsFAQ1f+MHSZE nj4MThgnuw6lhBgLyDaE X-Received: by 2002:a17:90b:3f10:b0:3ac:af8b:6f3 with SMTP id 98e67ed59e1d1-3b41cb0caa7mr14597812a91.52.1795627998826; Wed, 25 Nov 2026 09:33:18 -0800 (PST) Received: from a1-free ([2603:c021:8021:f000:0:1865:8c38:18fc]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b44b792474sm13334633a91.3.2026.11.25.09.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 09:33:18 -0800 (PST) From: TAKANO Mitsuhiro To: Arnaldo Carvalho de Melo , Namhyung Kim Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, TAKANO Mitsuhiro Subject: [PATCH] perf build: Replace the deprecated FileType with a helper Date: Wed, 25 Nov 2026 17:33:15 +0000 Message-ID: <20261125173315.2359128-1-takano32@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit pylint-tests and pylint-pmu-events hang off `all`, so with a pylint that reports W4904 the build fails on a tree nobody has changed. Measured on 7.4-rc4 with Python 3.14.9 and pylint 4.0.5, both targets exit 2 and pylint reports: - W4904 deprecated-class, argparse.FileType: pmu-events/jevents.py:1494 and :1496, tests/shell/lib/perf_json_output_lint.py:23 FileType is deprecated in the class's own terms - the docstring in 3.14 reads "Deprecated factory for creating file object types" - so the two jevents call sites and the one in the JSON output linter are replaced by a helper that opens the file, or hands back stdout or stdin for '-', which is what FileType did. The reader names its encoding, as the rest of the Python in perf does. Verification: pylint-tests and pylint-pmu-events exit 2 and 2 before this change and 0 and 0 after it. The generated pmu-events tables are byte identical either side of the change, checked by running jevents.py for arm64 and x86 over the same input tree and comparing pmu-events.c and pmu-events-string.c. Written with Hermes Agent, an LLM assistant; the author reviewed it and ran the build and the generator as described. Signed-off-by: TAKANO Mitsuhiro --- tools/perf/pmu-events/jevents.py | 19 ++++++++++++++++--- .../tests/shell/lib/perf_json_output_lint.py | 11 ++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index e083f7495e67..6974c58951a3 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -7,7 +7,7 @@ import json import metric import os import sys -from typing import (Callable, Dict, Optional, Sequence, Set, Tuple) +from typing import (Callable, Dict, Optional, Sequence, Set, TextIO, Tuple) import collections # Global command line arguments. @@ -1450,6 +1450,19 @@ def _init_worker(std_events: dict) -> None: global _arch_std_events _arch_std_events = std_events +def open_output(path: str) -> TextIO: + """Open path for writing, or hand back stdout for '-'. + + argparse.FileType is deprecated (its own docstring says so in 3.14) and + pylint 4 reports it, which fails the pylint-pmu-events target `all` needs. + """ + if path == '-': + return sys.stdout + try: + return open(path, 'w', encoding='utf-8') + except OSError as exc: + raise argparse.ArgumentTypeError(str(exc)) from exc + def main() -> None: global _args @@ -1491,9 +1504,9 @@ such as "arm/cortex-a34".''', help='Root of tree containing architecture directories containing json files' ) ap.add_argument( - 'output_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=sys.stdout) + 'output_file', type=open_output, nargs='?', default=sys.stdout) ap.add_argument( - 'output_string_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=None) + 'output_string_file', type=open_output, nargs='?', default=None) _args = ap.parse_args() _args.output_file.write(f"""/* SPDX-License-Identifier: GPL-2.0 */ diff --git a/tools/perf/tests/shell/lib/perf_json_output_lint.py b/tools/perf/tests/shell/lib/perf_json_output_lint.py index 8cde22ac9d97..9aafd03a8114 100644 --- a/tools/perf/tests/shell/lib/perf_json_output_lint.py +++ b/tools/perf/tests/shell/lib/perf_json_output_lint.py @@ -6,6 +6,15 @@ import argparse import sys import json +def open_input(path): + """Open path for reading, or hand back stdin for '-'.""" + if path == '-': + return sys.stdin + try: + return open(path, encoding='utf-8') + except OSError as exc: + raise argparse.ArgumentTypeError(str(exc)) from exc + ap = argparse.ArgumentParser() ap.add_argument('--no-args', action='store_true') ap.add_argument('--interval', action='store_true') @@ -20,7 +29,7 @@ ap.add_argument('--per-die', action='store_true') ap.add_argument('--per-node', action='store_true') ap.add_argument('--per-socket', action='store_true') ap.add_argument('--metric-only', action='store_true') -ap.add_argument('--file', type=argparse.FileType('r'), default=sys.stdin) +ap.add_argument('--file', type=open_input, default=sys.stdin) args = ap.parse_args() Lines = args.file.readlines() base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f -- 2.53.0