Place Ghantoos

Continuous integration – Python comments spellchecks with pylint, pyenchant and tox

As part of our continuous integration efforts, we always think about code quality and sometimes forget about the comments. To improve readability, the least we could do is spellcheck the comments to make sure we are not introducing new words into this world. Here is how I added spellchecks as part of my Python tox test suite of lshell, using pylint and pyenchant.

To test this locally, I had to install pyenchant and pylint. On Debian:

sudo apt-get install python-enchant pylint

As some of my comments included words that were not in the default en_US dictionary (mostly variable names, app names, etc.), I first ran pylint asking it to store all unknown words in a separate file. This can be done by specifying the argument: –spelling-store-unknown-words=y.

pylint --disable=all --enable=spelling --spelling-dict=en_US \
       --ignore-comments=no --spelling-store-unknown-words=y \
       --spelling-private-dict-file=test/words \
       path/to/code path/to/other/code

Read the rest of this entry »