]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rv/rvgen: replace __len__() calls with len()
authorWander Lairson Costa <wander@redhat.com>
Mon, 23 Feb 2026 16:17:47 +0000 (13:17 -0300)
committerGabriele Monaco <gmonaco@redhat.com>
Tue, 31 Mar 2026 14:47:51 +0000 (16:47 +0200)
commitb70bc5cca0e8873504cf3764f281b2d9094f9653
tree516c43c23ecbaebbad7a8b7fc37edf35a6890402
parent908f377f4a0fa4b0b86352af9cb858e6ffcc6e2d
rv/rvgen: replace __len__() calls with len()

Replace all direct calls to the __len__() dunder method with the
idiomatic len() built-in function across the rvgen codebase. This
change eliminates a Python anti-pattern where dunder methods are
called directly instead of using their corresponding built-in
functions.

The changes affect nine instances across two files. In automata.py,
the empty string check is further improved by using truthiness
testing instead of explicit length comparison. In dot2c.py, all
length checks in the get_minimun_type, __get_max_strlen_of_states,
and get_aut_init_function methods now use the standard len()
function. Additionally, spacing around keyword arguments has been
corrected to follow PEP 8 guidelines.

Direct calls to dunder methods like __len__() are discouraged in
Python because they bypass the language's abstraction layer and
reduce code readability. Using len() provides the same functionality
while adhering to Python community standards and making the code more
familiar to Python developers.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
Reviewed-by: Nam Cao <namcao@linutronix.de>
Link: https://lore.kernel.org/r/20260223162407.147003-5-wander@redhat.com
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
tools/verification/rvgen/rvgen/automata.py
tools/verification/rvgen/rvgen/dot2c.py