### Install Codespell from GitHub with User Permissions Source: https://github.com/codespell-project/codespell/blob/main/README.rst If pip installation encounters permission errors, use the --user flag to install codespell from GitHub to the user's local directory. ```sh pip install --user --upgrade git+https://github.com/codespell-project/codespell.git ``` -------------------------------- ### Install Codespell from GitHub Source: https://github.com/codespell-project/codespell/blob/main/README.rst Install or upgrade codespell directly from its GitHub repository. This command fetches the latest development version. ```sh pip install --upgrade git+https://github.com/codespell-project/codespell.git ``` -------------------------------- ### Install Codespell Source: https://github.com/codespell-project/codespell/blob/main/README.rst Install codespell using pip. Ensure you have Python 3.9 or above. ```sh pip install codespell ``` -------------------------------- ### Codespell Command-Line Equivalent Source: https://github.com/codespell-project/codespell/blob/main/README.rst This command demonstrates how to achieve the same configuration as the INI and TOML examples using command-line arguments. ```sh codespell --skip "*.po,*.ts,./src/3rdParty,./src/3rdParty" --count --quiet-level 3 ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/codespell-project/codespell/blob/main/README.rst Install required dependencies for development within a checkout of the codespell source. Ensure pip, setuptools, and wheel are up to date before running. ```sh pip install --upgrade pip setuptools setuptools_scm wheel ``` ```sh pip install -e . --group dev ``` -------------------------------- ### Codespell Useful Commands Example Source: https://github.com/codespell-project/codespell/blob/main/README.rst An example command to list typos, excluding translation files and specific directories, with quiet level 3 and no terminal colors. ```sh codespell -d -q 3 --skip="*.po,*.ts,./src/3rdParty,./src/Test" ``` -------------------------------- ### Codespell with Skip Files/Directories Source: https://github.com/codespell-project/codespell/blob/main/README.rst Provide a comma-separated list of files or directories to skip. Globs are accepted. This example skips .eps and .txt files, and specific directories. ```sh codespell --skip="*.eps,*.txt" ``` ```sh codespell --skip="./src/3rd-Party,./src/Test" ``` -------------------------------- ### Handling Special Characters in Config Source: https://github.com/codespell-project/codespell/blob/main/README.rst When values in a config file entry need to start with a '-', structure them as shown to avoid invalid entries. This ensures correct parsing of options like 'dictionary' and 'ignore-words-list'. ```ini [codespell] dictionary = mydict,- ignore-words-list = bar,-foo ``` -------------------------------- ### Run Tests Source: https://github.com/codespell-project/codespell/blob/main/README.rst Execute tests against the codebase using the make check command. ```sh make check ``` -------------------------------- ### Codespell Configuration in setup.cfg Source: https://github.com/codespell-project/codespell/blob/main/README.rst Configure codespell options like 'skip', 'count', and 'quiet-level' within an INI file named 'setup.cfg' or '.codespellrc'. Comments can be added using ';' or '#'. ```ini [codespell] skip = *.po,*.ts,./src/3rdParty,./src/Test count = quiet-level = 3 ``` -------------------------------- ### Sort Dictionaries Source: https://github.com/codespell-project/codespell/blob/main/README.rst Sort the project dictionaries using the make sort-dictionaries command. This is a required step before submitting a pull request. ```sh make check-dictionaries ``` ```sh make sort-dictionaries ``` -------------------------------- ### Update Dictionary File Source: https://github.com/codespell-project/codespell/blob/main/README.rst Download the latest dictionary.txt file and use it with codespell via the -D flag. This allows using updated dictionaries without updating the entire project. ```sh wget https://raw.githubusercontent.com/codespell-project/codespell/main/codespell_lib/data/dictionary.txt codespell -D dictionary.txt ``` -------------------------------- ### Codespell Interactive Mode with Write Changes Source: https://github.com/codespell-project/codespell/blob/main/README.rst Run codespell in interactive mode (level 3) and write changes directly to the files. ```sh codespell -i 3 -w ``` -------------------------------- ### Pre-commit Hook Configuration Source: https://github.com/codespell-project/codespell/blob/main/README.rst Integrate codespell into your pre-commit workflow by adding this configuration to your '.pre-commit-config.yaml' file. For Python versions prior to 3.11, 'tomli' may be required. ```yaml - repo: https://github.com/codespell-project/codespell rev: v2.4.1 hooks: - id: codespell ``` ```yaml - repo: https://github.com/codespell-project/codespell rev: v2.4.1 hooks: - id: codespell additional_dependencies: - tomli ``` -------------------------------- ### Run Codespell on Specific Files/Directories Source: https://github.com/codespell-project/codespell/blob/main/README.rst Specify files, directories, or glob patterns to check with codespell. ```sh codespell some_file some_dir/ *.ext ``` -------------------------------- ### Dictionary Entry with Multiple Suggestions Source: https://github.com/codespell-project/codespell/blob/main/README.rst When multiple suggestions are provided, a trailing comma is mandatory to ensure all suggestions are recognized. Automatic fixing is not possible in this case. ```text fiel->feel, field, file, phial, ``` -------------------------------- ### Codespell Configuration in pyproject.toml Source: https://github.com/codespell-project/codespell/blob/main/README.rst Configure codespell options within the '[tool.codespell]' section of a 'pyproject.toml' file. This format is equivalent to the INI configuration. ```toml [tool.codespell] skip = '*.po,*.ts,./src/3rdParty,./src/Test' count = true quiet-level = 3 ``` -------------------------------- ### Codespell with Comma-Separated Ignore Words Source: https://github.com/codespell-project/codespell/blob/main/README.rst Provide a comma-separated list of words to ignore directly on the command line. Ignore words are case-sensitive. ```sh codespell -L word1,word2,word3,word4 ``` -------------------------------- ### Simple Dictionary Entry Source: https://github.com/codespell-project/codespell/blob/main/README.rst A basic dictionary entry format where one incorrect word maps to one correct suggestion. ```text calulated->calculated ```