Skip to contentSkip to conversation

checkpatch: use python3 to find codespell dictionary

PATCH In review Kory Maincent 2 participants 2 messages Sep 29, 2025 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: use python3 to find codespell dictionary

From: Sagar Patel <[email protected]>

Import Linux patch to locate codespell dictionary:
https://lore.kernel.org/lkml/[email protected]/

codespell requires Python 3.6 or above, but on some systems, the python executable is a Python 2.7 interpreter. In this case, searching for the dictionary fails, subsequently making codespell fail:

No codespell typos will be found - file '/usr/share/codespell/dictionary.txt': No such file or directory

So, use python3 to remove ambiguity.

In addition, when searching for dictionary.txt, do not check if the codespell executable exists since,

- checkpatch.pl only uses dictionary.txt, not the codespell executable.

- codespell can be installed via a Python package manager, in which case the codespell executable may not be present in a typical $PATH, but a dictionary does exist.

---
 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
index 763287e02b1..b0ee126bd89 100755
@@ -337,7 +337,7 @@ if ($user_codespellfile) {
 } elsif (!(-f $codespellfile)) {
 	# If /usr/share/codespell/dictionary.txt is not present, try to find it
 	# under codespell's install directory: <codespell_root>/data/dictionary.txt
-	if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") {
+	if (($codespell || $help) && which("python3") ne "") {
 		my $python_codespell_dict = << "EOF";
 
 import os.path as op
@@ -347,7 +347,7 @@ codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt')
 print(codespell_file, end='')
 EOF
 
-		my $codespell_dict = `python -c "$python_codespell_dict" 2> /dev/null`;
+		my $codespell_dict = `python3 -c "$python_codespell_dict" 2> /dev/null`;
 		$codespellfile = $codespell_dict if (-f $codespell_dict);
 	}
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines · Kory Maincent

From: Sagar Patel <[email protected]>

Import Linux patch to locate codespell dictionary:
https://lore.kernel.org/lkml/[email protected]/

Please re-sync our copy of checkpatch.pl with v6.17 to bring in this change along with others we're missing. It should be clear enough what changes are local to U-Boot (it's almost all contained within a function now, and so the call to that function, but also just now, running some code checks on .env files). Thanks!

Signature · 1 line
Tom