* [PATCH] perf build: Replace the deprecated FileType with a helper
@ 2026-11-25 17:33 TAKANO Mitsuhiro
2026-11-25 17:36 ` sashiko-bot
2026-11-25 19:23 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: TAKANO Mitsuhiro @ 2026-11-25 17:33 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim
Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Mark Rutland,
linux-perf-users, linux-kernel, TAKANO Mitsuhiro
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 <takano32@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf build: Replace the deprecated FileType with a helper
2026-11-25 17:33 [PATCH] perf build: Replace the deprecated FileType with a helper TAKANO Mitsuhiro
@ 2026-11-25 17:36 ` sashiko-bot
2026-11-25 19:23 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-25 17:36 UTC (permalink / raw)
To: TAKANO Mitsuhiro; +Cc: linux-perf-users
> 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 <takano32@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125173315.2359128-1-takano32@gmail.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf build: Replace the deprecated FileType with a helper
2026-11-25 17:33 [PATCH] perf build: Replace the deprecated FileType with a helper TAKANO Mitsuhiro
2026-11-25 17:36 ` sashiko-bot
@ 2026-11-25 19:23 ` Namhyung Kim
2026-11-26 10:19 ` TAKANO Mitsuhiro
1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2026-11-25 19:23 UTC (permalink / raw)
To: TAKANO Mitsuhiro
Cc: Arnaldo Carvalho de Melo, Ian Rogers, Peter Zijlstra, Ingo Molnar,
Mark Rutland, linux-perf-users, linux-kernel
On Wed, Nov 25, 2026 at 05:33:15PM +0000, TAKANO Mitsuhiro wrote:
> 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.
>
I think we have a pending patch already.
https://lore.kernel.org/r/20261115003507.1872482-1-lalitmaganti@gmail.com
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf build: Replace the deprecated FileType with a helper
2026-11-25 19:23 ` Namhyung Kim
@ 2026-11-26 10:19 ` TAKANO Mitsuhiro
0 siblings, 0 replies; 4+ messages in thread
From: TAKANO Mitsuhiro @ 2026-11-26 10:19 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ian Rogers, linux-perf-users,
TAKANO Mitsuhiro
Hi Namhyung,
thanks, I see it now: Lalit Maganti's patch of 2026-11-15
https://lore.kernel.org/r/20261115003507.1872482-1-lalitmaganti@gmail.com
replaces FileType at the same three call sites (jevents.py:1494 and :1496,
perf_json_output_lint.py:23). It predates mine, so please drop mine and take
his. I am not sending a v2.
My duplicate check searched for my subject and for the lines I changed; his
patch touches the same call sites but the lines read differently, so nothing
matched. The check now also searches for the identifiers the patch removes
(FileType here), which does find his post.
Takano
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 17:33 [PATCH] perf build: Replace the deprecated FileType with a helper TAKANO Mitsuhiro
2026-11-25 17:36 ` sashiko-bot
2026-11-25 19:23 ` Namhyung Kim
2026-11-26 10:19 ` TAKANO Mitsuhiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox