Skip to contentSkip to conversation

prep --check: Add support to spellcheck if codespell is installed

PATCH Applied Marcos Paulo de Souza 2 participants 2 messages Nov 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 prep --check: Add support to spellcheck if codespell is installed

This commit adds --codespell to checkpatch.pl is the codespell package is installed.

If b4 is installed with pipx you need to use --system-site-packages when calling install, otherwise it won't see the packages installed by your package manager.

---
@mricon this new feature was added since I forgot to run checkpatch.pl --codespell when sending the patch to the ML. I believed that b4 would do such check, but I was mistaken. What do you think about it?
---
Changes in v2:
- Fixed typos in the commit message

---
 src/b4/ez.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/b4/ez.py +8 -1
index 57bc1ca..1c70f7f 100644
@@ -43,6 +43,12 @@ try:
 except ModuleNotFoundError:
     can_gfr = False
 
+try:
+    import codespell_lib
+    can_codespell = True
+except ModuleNotFoundError:
+    can_codespell = False
+
 logger = b4.logger
 
 MAGIC_MARKER = '--- b4-submit-tracking ---'
@@ -1809,7 +1815,8 @@ def get_check_cmds() -> Tuple[List[str], List[str]]:
         if topdir:
             checkpatch = os.path.join(topdir, 'scripts', 'checkpatch.pl')
             if os.access(checkpatch, os.X_OK):
-                ppcmds = [f'{checkpatch} -q --terse --no-summary --mailback --showfile']
+                spell = "--codespell" if can_codespell else ""
+                ppcmds = [f'{checkpatch} -q --terse --no-summary --mailback --showfile {spell}']
 
     # TODO: support for a whole-series check command, (pytest, etc)
     return ppcmds, scmds

---
base-commit: 509f56ff5c24e2ad48cd2621e54c67910ea19fc1
change-id: 20251107-check-codespell-68212aaf880e

Best regards,

Signature · 1 line
Marcos Paulo de Souza <[email protected]>
#1 lore raw
Quoted 8 lines · Marcos Paulo de Souza

This commit adds --codespell to checkpatch.pl is the codespell package is installed.

If b4 is installed with pipx you need to use --system-site-packages when calling install, otherwise it won't see the packages installed by your package manager.

[...]

Applied, thanks!

[1/1] prep --check: Add support to spellcheck if codespell is installed

      commit: 0f736aa3d4bf71a9139ce9c46054b5f1b38ac45e

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>