Giter Site home page Giter Site logo

codespell's Introduction

codespell

Fix common misspellings in text files. It's designed primarily for checking misspelled words in source code (backslash escapes are skipped), but it can be used with other files as well. It does not check for word membership in a complete dictionary, but instead looks for a set of common misspellings. Therefore it should catch errors like "adn", but it will not catch "adnasdfasdf". This also means it shouldn't generate false-positives when you use a niche term it doesn't know about.

Requirements

Python 3.8 or above.

Installation

You can use pip to install codespell with e.g.:

pip install codespell

Usage

Below are some simple usage examples to demonstrate how the tool works. For exhaustive usage information, please check the output of codespell -h.

Run codespell in all files of the current directory:

codespell

Run codespell in specific files or directories (specified via their names or glob patterns):

codespell some_file some_dir/ *.ext

Some noteworthy flags:

codespell -w, --write-changes

The -w flag will actually implement the changes recommended by codespell. Running without the -w flag is the same as doing a dry run. It is recommended to run this with the -i or --interactive flag.

codespell -I FILE, --ignore-words=FILE

The -I flag can be used for a list of certain words to allow that are in the codespell dictionaries. The format of the file is one word per line. Invoke using: codespell -I path/to/file.txt to execute codespell referencing said list of allowed words. See Ignoring Words for more details.

codespell -L word1,word2,word3,word4

The -L flag can be used to allow certain words that are comma-separated placed immediately after it. See Ignoring Words for more details.

codespell -x FILE, --exclude-file=FILE

Ignore whole lines that match those in FILE. The lines in FILE should match the to-be-excluded lines exactly.

codespell -S, --skip=

Comma-separated list of files to skip. It accepts globs as well. Examples:

  • to skip .eps & .txt files, invoke codespell --skip="*.eps,*.txt"
  • to skip directories, invoke codespell --skip="./src/3rd-Party,./src/Test"

Useful commands:

codespell -d -q 3 --skip="*.po,*.ts,./src/3rdParty,./src/Test"

List all typos found except translation files and some directories. Display them without terminal colors and with a quiet level of 3.

codespell -i 3 -w

Run interactive mode level 3 and write changes to file.

We ship a collection of dictionaries that are an improved version of the one available on Wikipedia after applying them in projects like Linux Kernel, EFL, oFono among others. You can provide your own version of the dictionary, but patches for new/different entries are very welcome.

Want to know if a word you're proposing exists in codespell already? It is possible to test a word against the current set dictionaries that exist in codespell_lib/data/dictionary*.txt via:

echo "word" | codespell -
echo "1stword,2ndword" | codespell -

You can select the optional dictionaries with the --builtin option.

Ignoring words

When ignoring false positives, note that spelling errors are case-insensitive but words to ignore are case-sensitive. For example, the dictionary entry wrod will also match the typo Wrod, but to ignore it you must pass wrod.

The words to ignore can be passed in two ways:

  1. -I: A file with a word per line to ignore:

    codespell -I FILE, --ignore-words=FILE
  2. -L: A comma separated list of words to ignore on the command line:

    codespell -L word1,word2,word3,word4

Inline ignore

Some situation might require ignoring a specific word in a specific location. This can be achieved by adding a comment in the source code. You can either ignore a single word or a list of words. The comment should be in the format of codespell:ignore <words>. Words should be separated by a comma.

  1. ignore specific word:

    def wrod() # codespell:ignore wrod
        pass
  2. ignore multiple words:

    def wrod(wrods) # codespell:ignore
        pass

Using a config file

Command line options can also be specified in a config file.

When running codespell, it will check in the current directory for a file named setup.cfg or .codespellrc (or a file specified via --config), containing an entry named [codespell]. Each command line argument can be specified in this file (without the preceding dashes), for example:

[codespell]
skip = *.po,*.ts,./src/3rdParty,./src/Test
count =
quiet-level = 3

The .codespellrc file is an INI file, which is read using Python's configparser. For example, comments are possible using ; or # as the first character.

Codespell will also check in the current directory for a pyproject.toml (or a path can be specified via --toml <filename>) file, and the [tool.codespell] entry will be used, but only if the tomli package is installed for versions of Python prior to 3.11. For example:

[tool.codespell]
skip = '*.po,*.ts,./src/3rdParty,./src/Test'
count = true
quiet-level = 3

These are both equivalent to running:

codespell --quiet-level 3 --count --skip "*.po,*.ts,./src/3rdParty,./src/Test"

If several config files are present, they are read in the following order:

  1. pyproject.toml (only if the tomli library is available)
  2. setup.cfg
  3. .codespellrc
  4. any additional file supplied via --config

If a codespell configuration is supplied in several of these files, the configuration from the most recently read file overwrites previously specified configurations.

Any options specified in the command line will override options from the config files.

pre-commit hook

codespell also works with pre-commit, using

- repo: https://github.com/codespell-project/codespell
  rev: v2.2.4
  hooks:
  - id: codespell

If one configures codespell using the pyproject.toml file instead use:

- repo: https://github.com/codespell-project/codespell
  rev: v2.2.4
  hooks:
  - id: codespell
    additional_dependencies:
      - tomli

Dictionary format

The format of the dictionaries was influenced by the one they originally came from, i.e. from Wikipedia. The difference is how multiple options are treated and that the last argument is an optional reason why a certain entry could not be applied directly, but should instead be manually inspected. E.g.:

  1. Simple entry: one wrong word / one suggestion:

    calulated->calculated
  2. Entry with more than one suggested fix:

    fiel->feel, field, file, phial,

    Note the last comma! You need to use it, otherwise the last suggestion will be discarded (see below for why). When there is more than one suggestion, an automatic fix is not possible and the best we can do is to give the user the file and line where the error occurred as well as the suggestions.

  3. Entry with one word, but with automatic fix disabled:

    clas->class, disabled because of name clash in c++

    Note that there isn't a comma at the end of the line. The last argument is treated as the reason why a suggestion cannot be automatically applied.

    There can also be multiple suggestions but any automatic fix will again be disabled:

    clas->class, clash, disabled because of name clash in c++

Development setup

As suggested in the Python Packaging User Guide, ensure pip, setuptools, and wheel are up to date before installing from source. Specifically you will need recent versions of setuptools and setuptools_scm:

pip install --upgrade pip setuptools setuptools_scm wheel

You can install required dependencies for development by running the following within a checkout of the codespell source:

pip install -e ".[dev]"

To run tests against the codebase run:

make check

Sending pull requests

If you have a suggested typo that you'd like to see merged please follow these steps:

  1. Make sure you read the instructions mentioned in the Dictionary format section above to submit correctly formatted entries.
  2. Choose the correct dictionary file to add your typo to. See codespell --help for explanations of the different dictionaries.
  3. Sort the dictionaries. This is done by invoking (in the top level directory of codespell/):

    make check-dictionaries

    If the make script finds that you need to sort a dictionary, please then run:

    make sort-dictionaries
  4. Only after this process is complete do we recommend you submit the PR.

Important Notes:

  • If the dictionaries are submitted without being pre-sorted the PR will fail via our various CI tools.
  • Not all PRs will be merged. This is pending on the discretion of the devs, maintainers, and the community.

Updating

To stay current with codespell developments it is possible to build codespell from GitHub via:

pip install --upgrade git+https://github.com/codespell-project/codespell.git

Important Notes:

  • Sometimes installing via pip will complain about permissions. If this is the case then run with:

    pip install --user --upgrade git+https://github.com/codespell-project/codespell.git
  • It has been reported that after installing from pip, codespell can't be located. Please check the $PATH variable to see if ~/.local/bin is present. If it isn't then add it to your path.
  • If you decide to install via pip then be sure to remove any previously installed versions of codespell (via your platform's preferred app manager).

Updating the dictionaries

In the scenario where the user prefers not to follow the development version of codespell yet still opts to benefit from the frequently updated dictionary files, we recommend running a simple set of commands to achieve this:

wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txt
codespell -D dictionary.txt

The above simply downloads the latest dictionary.txt file and then by utilizing the -D flag allows the user to specify the freshly downloaded dictionary.txt as the custom dictionary instead of the default one.

You can also do the same thing for the other dictionaries listed here:

https://github.com/codespell-project/codespell/tree/master/codespell_lib/data

License

The Python script codespell with its library codespell_lib is available with the following terms: (tl;dr: GPL v2)

Copyright (C) 2010-2011 Lucas De Marchi <[email protected]>

Copyright (C) 2011 ProFUSION embedded systems

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>.

dictionary.txt and the other dictionary_*.txt files are derivative works of English Wikipedia and are released under the Creative Commons Attribution-Share-Alike License 3.0.

codespell's People

Contributors

anatol avatar arm-in avatar bl-ue avatar cfi-gb avatar dimitripapadopoulos avatar edwardbetts avatar fishilico avatar fourchaux avatar gelma avatar int-y1 avatar janosh avatar jdufresne avatar jonmeow avatar korverdev avatar larsoner avatar lucasdemarchi avatar lurch avatar matkoniecz avatar pabs3 avatar peternewman avatar pre-commit-ci[bot] avatar qyearsley avatar robin-wayve avatar sebweb3r avatar skangas avatar stweil avatar sylvestre avatar tkoyama010 avatar vikivivi avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codespell's Issues

README: outdated license notice

README says:

The Python script codespell.py is available with the following terms:

But currently codespell.py is just a thin wrapper over codespell_lib, with little to no creativity.
This sentence should probably read something like this:

The Python code is available with the following terms:

Interactive lvl 1 has undesired behavior

When running interactive lvl 1, once a potential spelling fix is rejected, it is automatically accepted for subsequent matches. The cause is that once a fix is rejected, that match is handled as a list of available fixes.

It would be preferred behavior to either skip subsequent matches altogether, or to prompt for confirmation each time.

Codespell does not work with an empty line in dictionary

Codespell does not work with an empty line in the dictionary. This error can easily reproduced by added an empty line into the dictionary.txt -file an run codespell. The output will be:

Traceback (most recent call last):
File "/usr/bin/codespell.py", line 526, in
sys.exit(main(*sys.argv))
File "/usr/bin/codespell.py", line 473, in main
build_dict(args[0])
File "/usr/bin/codespell.py", line 265, in build_dict
[key, data] = line.split('->')
ValueError: need more than 1 value to unpack

If this is an intentional behaviour, feel free to close this issue.

Best regards

Martin Ettl

ImportError: No module named 'codespell_lib'

I using codespell on scrutinizer which is a ci

unfortunately it doesn't work

My commands are:

pip install codespell

Collecting codespell
  Downloading codespell-1.9.2.tar.gz (45kB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 51kB 4.2MB/s 
25hBuilding wheels for collected packages: codespell
  Running setup.py bdist_wheel for codespell ... 25l- done
25h  Stored in directory: /home/scrutinizer/.cache/pip/wheels/20/42/eb/32e6da9b97cf208b6e9cecaaf9c08e324f1826a136c721637f
Successfully built codespell
Installing collected packages: codespell
Successfully installed codespell-1.9.2

if I then try to run the command with something like:

python ../bin/codespell.py app/Config/core.php
The command exited with code 1.

Traceback (most recent call last):
  File "../bin/codespell.py", line 6, in 
    import codespell_lib
ImportError: No module named 'codespell_lib'

it doesn't work untill I add a full path to PYTHONPATH which I dont think is expected

manpage

Hi Lucas!

Thank you for providing codespell, I use it almost every day.

I recognized that there is no manpage for this tool. It would be nice to have one. However Paul Wise hinted that there might occur inconsistencies between the manpage and the --help option.

See here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779900

What do you think about adding a git help like approach for --help and the manpage?

Greetings
Peter

Ignoring directories

Hello,

I would like to ignore everything that's in (or anywhere below) a specific directory. This currently doesn't seem to be supported, though.
Would you mind implementing it?

Thanks for the useful tool!

Update PyPi please?

The version of codespell on pypi is 1.9.2, which is almost 9 months old (and doesn't have support for loading multiple dictionaries).

Could we have a new release please? :-)

Makefile is broken

The makefile is no longer working, since there is no longer a codespell.py

unable to run codespell.py on debian lenny with python 3.2.1

$ python3 --version
Python 3.2.1

Here is the traceback:

$./codespell.py dictionary.txt dictionary.txt
Traceback (most recent call last):
File "./codespell.py", line 526, in
sys.exit(main(*sys.argv))
File "./codespell.py", line 473, in main
build_dict(args[0])
File "./codespell.py", line 264, in build_dict
for line in f:
File "/usr/local/lib/python3.2/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3170: ordinal not in range(128)

What do you suggest?

Many thanks

Martin

Any change of adding this to PyPi?

Our project installs tools via pip to keep things nice and clean and virtualenv friendly--It would be great if codespell was added to Pypi.

How to handle two correct spellings?

Currently the dictionary changes modeled to modelled. However, both spellings are correct, though modeled is preferred. Is the best way to handle this to remove the line, or to reverse it so that the preferred spelling, modeled, is used?

isnt is a command in CoffeScript

isnt is a command in CoffeScript and therefore no spelling mistake for .coffee (or .jade) files. Is it possible to add something like whitelists depending on the file type?

codespell: command not found

Installed with a raspberry pi running Raspian Stretch and I'm getting the error:

bash: codespell: command not found

trying to run the following command:

codespell -h

I ran

pip install codespell

and the build was successful and I made sure to check in ~/.local/bin to see if codespell was in there and it was indeed located there.

Any ideas?

make install fails to create codespell from codespell.py

vagrant@debian:/.codespell (master)$ make install
sort: data/dictionary.txt:274: disorder: Amercia->America
Dictionary not sorted. Sort with 'make sort-dictionary'
make: *** [check-dictionary] Error 1
vagrant@debian:
/.codespell (master)$ make sort-dictionary
LANG=C sort -f -u -o data/dictionary.txt data/dictionary.txt
vagrant@debian:~/.codespell (master)$ make install --debug=v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu
Reading makefiles...
Reading makefile Makefile'... Updating goal targets.... Considering target fileinstall'.
File install' does not exist. Considering target filecodespell'.
File codespell' does not exist. Considering target filecodespell.py'.
Finished prerequisites of target file codespell.py'. No need to remake targetcodespell.py'.
Considering target file check-dictionary'. Filecheck-dictionary' does not exist.
Finished prerequisites of target file check-dictionary'. Must remake targetcheck-dictionary'.
sort: data/dictionary.txt:274: disorder: Amercia->America
Dictionary not sorted. Sort with 'make sort-dictionary'
make: *** [check-dictionary] Error 1
vagrant@debian:/.codespell (master)$ ./codespell
-bash: ./codespell: No such file or directory
vagrant@debian:
/.codespell (master)$ ls -lA
total 72
-rw-r--r-- 1 vagrant vagrant 439 Sep 9 21:25 codespell.1.include
-rwxr-xr-x 1 vagrant vagrant 17900 Sep 9 21:25 codespell.py
-rw-r--r-- 1 vagrant vagrant 18092 Sep 9 21:25 COPYING
drwxr-xr-x 2 vagrant vagrant 4096 Sep 9 21:25 data
drwxr-xr-x 2 vagrant vagrant 4096 Sep 9 21:25 example
drwxr-xr-x 8 vagrant vagrant 4096 Sep 9 21:26 .git
-rw-r--r-- 1 vagrant vagrant 2223 Sep 9 21:25 Makefile
-rw-r--r-- 1 vagrant vagrant 294 Sep 9 21:25 NEWS
-rw-r--r-- 1 vagrant vagrant 3035 Sep 9 21:25 README.md
-rw-r--r-- 1 vagrant vagrant 107 Sep 9 21:25 TODO

Where in the documentation does it say Python 3 is a requirement?

Please update README.md. On a CentOS 6.6 system (python 2.6.6), I received the following message after attempting to execute codespell.py:

$ python codespell.py
File "codespell.py", line 146
file=sys.stderr)
^
SyntaxError: invalid syntax

$ ./codespell.py
/usr/bin/env: python3: No such file or directory

Also, in the Usage section, it should be './codespell.py -h' and not './codespell -h'.

Pass specific words to -I flag as parameters instead of needing to use a file

Thanks to @thdot per #100 we can now use -I <file name> to ignore certain words. Each word needs to be on a separate line in the file. That is great when there is a place to save a whitelist file to so codespell can read it.

But say we were in a Buildbot environment, an automated testing framework, where we've setup codespell as a unit test... and so there isn't an easy possibility to save a whitelist file somewhere? Or another scenario, we're trying to quickly filter out a ginormous list of false positives from a codespell result, one needs to open their favorite editor and add each word on a separate line and link said file. It's not the most efficient.

It would be then useful to then have the the ability to pass the whitelisted words sequentially ex. codespell -I 'nto,ans,pres,ot,amin'
Thoughts?

pep8 warnings

Hi Lucas!

pep8 --ignore W191 . generates lots of warnings.

Could you fix them?

Greetings
Peter

./codespell.py:37:14: E201 whitespace after '['
./codespell.py:37:36: E202 whitespace before ']'
./codespell.py:40:80: E501 line too long (104 > 79 characters)
./codespell.py:42:1: E265 block comment should start with '# '
./codespell.py:44:1: E265 block comment should start with '# '
./codespell.py:49:1: E302 expected 2 blank lines, found 1
./codespell.py:57:1: E302 expected 2 blank lines, found 1
./codespell.py:74:1: E302 expected 2 blank lines, found 1
./codespell.py:80:1: E302 expected 2 blank lines, found 1
./codespell.py:93:1: E302 expected 2 blank lines, found 1
./codespell.py:107:80: E501 line too long (116 > 79 characters)
./codespell.py:109:1: E302 expected 2 blank lines, found 1
./codespell.py:146:57: E127 continuation line over-indented for visual indent
./codespell.py:150:33: E127 continuation line over-indented for visual indent
./codespell.py:158:5: E303 too many blank lines (2)
./codespell.py:170:57: E127 continuation line over-indented for visual indent
./codespell.py:172:57: E127 continuation line over-indented for visual indent
./codespell.py:173:57: E127 continuation line over-indented for visual indent
./codespell.py:174:80: E501 line too long (80 > 79 characters)
./codespell.py:175:57: E127 continuation line over-indented for visual indent
./codespell.py:191:1: E302 expected 2 blank lines, found 1
./codespell.py:194:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:194:33: E251 unexpected spaces around keyword / parameter equals
./codespell.py:196:25: E127 continuation line over-indented for visual indent
./codespell.py:196:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:196:33: E251 unexpected spaces around keyword / parameter equals
./codespell.py:196:53: E251 unexpected spaces around keyword / parameter equals
./codespell.py:196:55: E251 unexpected spaces around keyword / parameter equals
./codespell.py:197:25: E127 continuation line over-indented for visual indent
./codespell.py:197:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:197:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:199:25: E127 continuation line over-indented for visual indent
./codespell.py:199:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:199:33: E251 unexpected spaces around keyword / parameter equals
./codespell.py:199:52: E251 unexpected spaces around keyword / parameter equals
./codespell.py:199:54: E251 unexpected spaces around keyword / parameter equals
./codespell.py:200:25: E127 continuation line over-indented for visual indent
./codespell.py:200:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:200:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:200:80: E501 line too long (82 > 79 characters)
./codespell.py:202:25: E127 continuation line over-indented for visual indent
./codespell.py:202:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:202:33: E251 unexpected spaces around keyword / parameter equals
./codespell.py:202:55: E251 unexpected spaces around keyword / parameter equals
./codespell.py:202:57: E251 unexpected spaces around keyword / parameter equals
./codespell.py:203:25: E127 continuation line over-indented for visual indent
./codespell.py:203:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:203:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:205:25: E127 continuation line over-indented for visual indent
./codespell.py:205:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:205:33: E251 unexpected spaces around keyword / parameter equals
./codespell.py:206:25: E127 continuation line over-indented for visual indent
./codespell.py:206:32: E251 unexpected spaces around keyword / parameter equals
./codespell.py:206:34: E251 unexpected spaces around keyword / parameter equals
./codespell.py:207:25: E127 continuation line over-indented for visual indent
./codespell.py:207:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:207:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:207:80: E502 the backslash is redundant between brackets
./codespell.py:208:77: E502 the backslash is redundant between brackets
./codespell.py:213:25: E127 continuation line over-indented for visual indent
./codespell.py:213:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:213:33: E251 unexpected spaces around keyword / parameter equals
./codespell.py:213:55: E251 unexpected spaces around keyword / parameter equals
./codespell.py:213:57: E251 unexpected spaces around keyword / parameter equals
./codespell.py:214:25: E127 continuation line over-indented for visual indent
./codespell.py:214:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:214:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:217:25: E127 continuation line over-indented for visual indent
./codespell.py:217:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:217:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:217:76: E502 the backslash is redundant between brackets
./codespell.py:218:75: E502 the backslash is redundant between brackets
./codespell.py:219:73: E502 the backslash is redundant between brackets
./codespell.py:223:25: E127 continuation line over-indented for visual indent
./codespell.py:223:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:223:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:224:25: E127 continuation line over-indented for visual indent
./codespell.py:227:25: E127 continuation line over-indented for visual indent
./codespell.py:228:25: E127 continuation line over-indented for visual indent
./codespell.py:228:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:228:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:228:79: E502 the backslash is redundant between brackets
./codespell.py:229:33: E127 continuation line over-indented for visual indent
./codespell.py:229:79: E502 the backslash is redundant between brackets
./codespell.py:230:79: E502 the backslash is redundant between brackets
./codespell.py:231:73: E502 the backslash is redundant between brackets
./codespell.py:235:25: E127 continuation line over-indented for visual indent
./codespell.py:236:25: E127 continuation line over-indented for visual indent
./codespell.py:236:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:236:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:236:80: E502 the backslash is redundant between brackets
./codespell.py:237:33: E127 continuation line over-indented for visual indent
./codespell.py:237:77: E502 the backslash is redundant between brackets
./codespell.py:238:76: E502 the backslash is redundant between brackets
./codespell.py:239:78: E502 the backslash is redundant between brackets
./codespell.py:240:79: E502 the backslash is redundant between brackets
./codespell.py:241:75: E502 the backslash is redundant between brackets
./codespell.py:242:78: E502 the backslash is redundant between brackets
./codespell.py:246:25: E127 continuation line over-indented for visual indent
./codespell.py:246:53: E251 unexpected spaces around keyword / parameter equals
./codespell.py:246:55: E251 unexpected spaces around keyword / parameter equals
./codespell.py:247:25: E127 continuation line over-indented for visual indent
./codespell.py:247:29: E251 unexpected spaces around keyword / parameter equals
./codespell.py:247:31: E251 unexpected spaces around keyword / parameter equals
./codespell.py:247:77: E502 the backslash is redundant between brackets
./codespell.py:248:25: E127 continuation line over-indented for visual indent
./codespell.py:248:75: E502 the backslash is redundant between brackets
./codespell.py:249:77: E502 the backslash is redundant between brackets
./codespell.py:253:5: E303 too many blank lines (2)
./codespell.py:265:1: E302 expected 2 blank lines, found 1
./codespell.py:270:1: E302 expected 2 blank lines, found 1
./codespell.py:291:1: E302 expected 2 blank lines, found 1
./codespell.py:295:50: E127 continuation line over-indented for visual indent
./codespell.py:309:1: E302 expected 2 blank lines, found 1
./codespell.py:318:1: E302 expected 2 blank lines, found 1
./codespell.py:326:44: E222 multiple spaces after operator
./codespell.py:326:80: E501 line too long (80 > 79 characters)
./codespell.py:328:21: E701 multiple statements on one line (colon)
./codespell.py:367:1: E302 expected 2 blank lines, found 1
./codespell.py:411:44: E713 test for membership should be 'not in'
./codespell.py:425:80: E501 line too long (82 > 79 characters)
./codespell.py:430:80: E501 line too long (90 > 79 characters)
./codespell.py:443:45: E128 continuation line under-indented for visual indent
./codespell.py:444:45: E128 continuation line under-indented for visual indent
./codespell.py:452:73: E502 the backslash is redundant between brackets
./codespell.py:453:29: E127 continuation line over-indented for visual indent
./codespell.py:456:74: E202 whitespace before '}'
./codespell.py:458:69: E502 the backslash is redundant between brackets
./codespell.py:459:29: E127 continuation line over-indented for visual indent
./codespell.py:460:32: E201 whitespace after '{'
./codespell.py:462:32: E128 continuation line under-indented for visual indent
./codespell.py:462:74: E202 whitespace before '}'
./codespell.py:472:80: E501 line too long (81 > 79 characters)
./codespell.py:473:65: E127 continuation line over-indented for visual indent
./codespell.py:473:80: E501 line too long (80 > 79 characters)
./codespell.py:478:1: E302 expected 2 blank lines, found 1
./codespell.py:486:26: E703 statement ends with a semicolon

More elaborate documentation

  • Please explain how -x --exclude works. Thanks!
  • document how devs can use codespell in their Continuous Integration
  • elaborate on the --regex flag

What does 'disable due to \n' mean?

Codespell result looked like:
./App/AreaPyImp.cpp:163: nTo ==> not | disable due to \n

The code in question:

"\nTo ensure no stray abortion is left in the previous operation, it is advised to manually clear\n"

how to add "wrong" words to dictionary?

i want to add 'churchs' as a good word (a shoebrand!)
to my private dictionary, but codespell always want
to correct it with churchs->churches

what is the proposed way to do this?

codespell always has an exit value of zero

Even when there are spelling errors, codespell will exit with a 0. That makes it hard to fail a build step if the spell check fails.

I think it would be nice to exit with a value different than 0 in case of errros. Maybe optional behind a flag to not change the behaviour for existing users.

codespell ignores C/C++ tabs ('\t') in strings

I found out, that codespell gives wrong answers in case of a tab is used within a C/C++ string. For example:
test.c:

int main()
{
    std::cout<< "\tTest\n";
}

dict.txt:

ttest->test

Scanning with test.c with codespell gives a wrong result:

$ ../codespell.py dict.txt test.c 
test.c:3: tTest  ==> test

ImportError: No module named codespell_lib

I downloaded the script and ran it as:

$ ./vendor/lucasdemarchi/codespell/bin/codespell.py -h

but it gives:

Traceback (most recent call last):
  File "./vendor/lucasdemarchi/codespell/bin/codespell.py", line 6, in <module>
    import codespell_lib
ImportError: No module named codespell_lib

If I copy codespell.py one directory up and run that, it works.

CamelCase support?

Is it possible to treat camel case class names etc. as separate words, so that spelling errors could be found?

codespell.py does nothng if [fileN] is not specified

Previously running codespell without file parameter starts the check. Now codespell.py does nothing. The behavior should stay the same as before - if file/dir argument is not specefied then current directory should be used as a default parameter.

There is no ./codespell.py

README says:

Check usage with ./codespell.py -h

But there is no ./codespell.py (unless you cd into bin, in which case the command doesn't work either).

codespell.py was moved from . to bin in b400e42, but I don't understand why. The commit message is enigmatic.

Is it possible to detect wrong spelled words like this:

$ more test.cpp
enum
{
ID_ESTABLISED = 0;
};

$ more dictionary.txt

establised->established

$ codespell.py dictionary.txt
$

In this case codespell does not detect the error. But if i remove the preceeding ID_ from the enum definition, codespell is able
to detect the error. Is it possible to detect the errror without modification of the code?
Many thanks in advance

Martin Ettl

Python2 support

Would the devs be interested in me adding support for Python2? I've worked on a number of packages with support for Python2 and Python3, so I don't expect it would be too bad.

Unused dictionary entries

Some entries in the dictionary will never be used by codespell, because they contain uppercase letters or spaces or punctuation characters:

$ LC_ALL=C grep -v -E "^[a-z0-9_'-]+->" codespell_lib/data/dictionary.txt
Amercia->America
Bernouilli->Bernoulli
Blitzkreig->Blitzkrieg
Bonnano->Bonanno
Brasillian->Brazilian
Britian->Britain
Brittish->British
Buddah->Buddha
Buddist->Buddhist
Cambrige->Cambridge
Capetown->Cape Town
Carmalite->Carmelite
Carnagie->Carnegie
Carnagie-Mellon->Carnegie-Mellon
Carnigie->Carnegie
Carnigie-Mellon->Carnegie-Mellon
Carribbean->Caribbean
Carribean->Caribbean
Carthagian->Carthaginian
Cataline->Catiline, Catalina,
Ceasar->Caesar
Celcius->Celsius
Champange->Champagne
Cincinatti->Cincinnati
Cincinnatti->Cincinnati
Coca Cola->Coca-Cola
Conneticut->Connecticut
Dardenelles->Dardanelles
Dravadian->Dravidian
Enlish->English, enlist,
Europian->European
Europians->Europeans
Eurpean->European
Eurpoean->European
Farenheit->Fahrenheit
Febuary->February
Feburary->February
Flemmish->Flemish
Formalhaut->Fomalhaut
Foundland->Newfoundland
Fransiscan->Franciscan
Fransiscans->Franciscans
Galations->Galatians
Gameboy->Game Boy
Ghandi->Gandhi
Godounov->Godunov
Gothenberg->Gothenburg
Gottleib->Gottlieb
Guaduloupe->Guadalupe, Guadeloupe,
Guadulupe->Guadalupe, Guadeloupe,
Guatamala->Guatemala
Guatamalan->Guatemalan
Guilia->Giulia
Guilio->Giulio
Guiness->Guinness
Guiseppe->Giuseppe
Habsbourg->Habsburg
Hallowean->Hallowe'en, Halloween,
Hatian->Haitian
Heidelburg->Heidelberg
Ihaca->Ithaca
Israelies->Israelis
Janurary->January
Januray->January
Japanes->Japanese
Johanine->Johannine
Jospeh->Joseph
Juadaism->Judaism
Juadism->Judaism
Lybia->Libya
Malcom->Malcolm
Massachussets->Massachusetts
Massachussetts->Massachusetts
Mediteranean->Mediterranean
Michagan->Michigan
MingGW->MinGW
Misouri->Missouri
Missisipi->Mississippi
Missisippi->Mississippi
Monserrat->Montserrat
Montnana->Montana
Morisette->Morissette
Morrisette->Morissette
Mythraic->Mithraic
Naploeon->Napoleon
Napolean->Napoleon
Napoleonian->Napoleonic
Nazereth->Nazareth
Newyorker->New Yorker
nightfa;;->nightfall
Novermber->November
Nullabour->Nullarbor
Nuremburg->Nuremberg
Palistian->Palestinian
Palistinian->Palestinian
Palistinians->Palestinians
Papanicalou->Papanicolaou
Peloponnes->Peloponnesus
Pennyslvania->Pennsylvania
Pharoah->Pharaoh
Philipines->Philippines
Phillipine->Philippine
Phillipines->Philippines
Phillippines->Philippines
Phonecian->Phoenecian
Portugese->Portuguese
Postdam->Potsdam
Premonasterians->Premonstratensians
Pucini->Puccini
Puertorrican->Puerto Rican
Puertorricans->Puerto Ricans
Queenland->Queensland
Rockerfeller->Rockefeller
Russion->Russian
Sacremento->Sacramento
Sanhedrim->Sanhedrin
Saterday->Saturday
Saterdays->Saturdays
Sionist->Zionist
Sionists->Zionists
Sixtin->Sistine
Skagerak->Skagerrak
Tolkein->Tolkien
Tuscon->Tucson
Ukranian->Ukrainian
UnitesStates->UnitedStates
Yementite->Yemenite, Yemeni,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.