Package: 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.Useful linksGitHub projectRepositoryReleasesRequirementsPython 3.8 or above.InstallationYou can usepipto install codespell with e.g.:pipinstallcodespellUsageBelow are some simple usage examples to demonstrate how the tool works.
For exhaustive usage information, please check the output ofcodespell-h.Run codespell in all files of the current directory:codespellRun codespell in specific files or directories (specified via their names or glob patterns):codespellsome_filesome_dir/*.extSome noteworthy flags:codespell-w,--write-changesThe-wflag will actually implement the changes recommended by codespell. Running without the-wflag is the same as doing a dry run. It is recommended to run this with the-ior--interactiveflag.codespell-IFILE,--ignore-words=FILEThe-Iflag 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-Ipath/to/file.txtto execute codespell referencing said list of allowed words. SeeIgnoring Wordsfor more details.codespell-Lword1,word2,word3,word4The-Lflag can be used to allow certain words that are comma-separated placed immediately after it.  SeeIgnoring Wordsfor more details.codespell-xFILE,--exclude-file=FILEIgnore whole lines that match those inFILE.  The lines inFILEshould 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, invokecodespell--skip="*.eps,*.txt"to skip directories, invokecodespell--skip="./src/3rd-Party,./src/Test"Useful commands:codespell-d-q3--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-i3-wRun interactive mode level 3 and write changes to file.We ship a collection of dictionaries that are an improved version of the one availableon Wikipediaafter 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 incodespell_lib/data/dictionary*.txtvia:echo"word"|codespell-echo"1stword,2ndword"|codespell-You can select the optional dictionaries with the--builtinoption.Ignoring WordsWhen ignoring false positives, note that spelling errors arecase-insensitivebut words to ignore arecase-sensitive. For example, the dictionary entrywrodwill also match the typoWrod, but to ignore it you must passwrod.The words to ignore can be passed in two ways:-I: A file with a word per line to ignore:codespell-IFILE,--ignore-words=FILE-L: A comma separated list of words to ignore on the command line:codespell-Lword1,word2,word3,word4Using a config fileCommand line options can also be specified in a config file.When runningcodespell, it will check in the current directory for a file
namedsetup.cfgor.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/Testcount=quiet-level=3Codespell will also check in the current directory for apyproject.toml(or a path can be specified via--toml<filename>) file, and the[tool.codespell]entry will be used, but only if thetomlipackage
is installed for versions of Python prior to 3.11. For example:[tool.codespell]skip='*.po,*.ts,./src/3rdParty,./src/Test'count=''quiet-level=3These are both equivalent to running:codespell--quiet-level3--count--skip"*.po,*.ts,./src/3rdParty,./src/Test"If several config files are present, they are read in the following order:pyproject.toml(only if thetomlilibrary is available)setup.cfg.codespellrcany additional file supplied via--configIf 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 willoverrideoptions from the
config files.pre-commithookcodespell also works withpre-commit, using-repo:https://github.com/codespell-project/codespellrev:v2.2.4hooks:-id:codespellIf one configures codespell using thepyproject.tomlfile instead use:-repo:https://github.com/codespell-project/codespellrev:v2.2.4hooks:-id:codespelladditional_dependencies:-tomliDictionary formatThe 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.:Simple entry: one wrong word / one suggestion:calulated->calculatedEntry 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.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 SetupAs suggested in thePython Packaging User Guide, ensurepip,setuptools, andwheelare up to date before installing from source. Specifically you will need recent versions ofsetuptoolsandsetuptools_scm:pipinstall--upgradepipsetuptoolssetuptools_scmwheelYou can install required dependencies for development by running the following within a checkout of the codespell source:pipinstall-e".[dev]"To run tests against the codebase run:makecheckSending Pull RequestsIf you have a suggested typo that you’d like to see merged please follow these steps:Make sure you read the instructions mentioned in theDictionary formatsection above to submit correctly formatted entries.Choose the correct dictionary file to add your typo to. Seecodespell –helpfor explanations of the different dictionaries.Sort the dictionaries. This is done by invoking (in the top level directory ofcodespell/):makecheck-dictionariesIf the make script finds that you need to sort a dictionary, please then run:makesort-dictionariesOnly 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.UpdatingTo stay current with codespell developments it is possible to build codespell from GitHub via:pipinstall--upgradegit+https://github.com/codespell-project/codespell.gitImportant Notes:Sometimes installing viapipwill complain about permissions. If this is the case then run with:pipinstall--user--upgradegit+https://github.com/codespell-project/codespell.gitIt has been reported that after installing frompip, codespell can’t be located. Please check the $PATH variable to see if~/.local/binis present. If it isn’t then add it to your path.If you decide to install viapipthen be sure to remove any previously installed versions of codespell (via your platform’s preferred app manager).Updating the dictionariesIn 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:wgethttps://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txtcodespell-Ddictionary.txtThe above simply downloads the latestdictionary.txtfile and then by utilizing the-Dflag allows the user to specify the freshly downloadeddictionary.txtas 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/dataLicenseThe Python scriptcodespellwith its librarycodespell_libis available
with the following terms:
(tl;dr:GPL v2)Copyright (C) 2010-2011  Lucas De Marchi <lucas.de.marchi@gmail.com>Copyright (C) 2011  ProFUSION embedded systemsThis 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.txtand the otherdictionary_*.txtfiles are derivative works of English Wikipedia and are released under theCreative Commons Attribution-Share-Alike License 3.0.