spellchecker for source code
kodespel is a spellchecker for source code.
It is implemented as a small Python script with
all the real work done in a library (package
kodespel's nifty trick is that it knows how to split common programming identifiers like 'getAllStuff' or 'DoThingsNow' or 'num_objects' or 'HTTPResponse' into words, feed those to ispell, and interpret ispell's output.
Requirements & installation
kodespel requires Python 3.6+ and ispell. To install ispell, use your OS-specific package manager (e.g. apt, dnf, brew, ...).
To install kodespel itself, use pip:
pip install --user kodespel
(Or install it in a virtualenv if you prefer.)
Basic usage is to run kodespel on one or more individual files or directories:
kodespel foo.py main.go README.md
kodespel uses a collection of dictionaries to spellcheck each file.
It always uses the
which is a set of words common in source code
across languages and platforms.
Additionally, there is a language-specific dictionary
for each language the kodespel knows about.
Language-specific dictionaries are automatically chosen for you.
In this example, kodespell will spellcheck each file with:
baseonly (no language dictionary for Markdown)
If run on a directory, kodespel will recurse into that directory and spellcheck every file that it recognizes:
will search for
*.h, and any other
extension that kodespel has built-in support for.
(Currently: Python, Perl, Go, C, C++, and Java.)
Unsupported files are ignored, but if you pass those filenames
explicitly, they will be checked.
kodespel ships with several other common dictionaries.
For example, if the program you are spellchecking uses
a lot of Unix system calls, you would add the
kodespel -d unix foo.py main.go README.md
-d option applies to every file being checked.
To see the list of all builtin dictionaries, run
Finally, you can create your own dictionaries, and use as many of them as you like. A dictionary is a plain text file with one word per line:
$ cat myproject.dict nargs args
You can specify your person dictionaries with
just like kodespel's builtin dictionaries:
kodespel -d unix -d myproject.dict foo.py ...
A tool with similar goals but a different implementation is codespell.
The main advantage of codespell is that it seems to have many fewer false positives.
The main advantage of kodespel is that it checks identifiers, not just comments and strings, so can find a lot more errors. And more false positives too, unfortunately.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.