Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
isaak654 authored Jan 8, 2025
2 parents 560bb9d + ec57cff commit a0a08df
Show file tree
Hide file tree
Showing 25 changed files with 5,472 additions and 301 deletions.
2 changes: 2 additions & 0 deletions .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
git config --global --add safe.directory /workspaces/codespell

sudo apt-get update
sudo apt-get install -y libaspell-dev

Expand Down
5 changes: 5 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
exclude:
authors:
- dependabot
- pre-commit-ci
10 changes: 7 additions & 3 deletions .github/workflows/codespell-private.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
REQUIRE_ASPELL: true
RUFF_OUTPUT_FORMAT: github
# Make sure we're using the latest aspell dictionary
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
Expand All @@ -25,6 +25,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
no-toml:
- ""
include:
Expand All @@ -39,6 +40,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- run: sudo apt-get install libaspell-dev aspell-en
- name: Install dependencies
run: |
Expand All @@ -50,11 +52,13 @@ jobs:
- run: codespell --help
- run: codespell --version
- run: make check
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
# tomli should not be required for the next two steps (and make sure it's not)
- run: pip uninstall -yq tomli
if: ${{ matrix.no-toml == 'no-toml' }}
- run: codespell --check-filenames --skip="./.git/*,*.pyc,./codespell_lib/tests/test_basic.py,./codespell_lib/data/*,./example/code.c,./build/lib/codespell_lib/tests/test_basic.py,./build/lib/codespell_lib/data/*,README.rst,*.egg-info/*,pyproject-codespell.precommit-toml,./.mypy_cache"
- run: codespell --check-filenames --skip="./.git/*,./.pytest_cache/*,./junit-results.xml,*.pyc,./codespell_lib/tests/test_basic.py,./codespell_lib/data/*,./example/code.c,./build/lib/codespell_lib/tests/test_basic.py,./build/lib/codespell_lib/data/*,README.rst,*.egg-info/*,pyproject-codespell.precommit-toml,./.mypy_cache"
# this file has an error
- run: "! codespell codespell_lib/tests/test_basic.py"

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/codespell-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ jobs:
- run: codespell --help
- run: codespell --version
- run: pytest codespell_lib
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
with:
check_filenames: true
# When using this Action in other repos, the --skip option below can be removed
skip: "./.git,./codespell_lib/data,./example/code.c,test_basic.py,*.pyc,README.rst,pyproject-codespell.precommit-toml"
skip: "./.git,./codespell_lib/data,./example/code.c,test_basic.py,./codespell_lib/tests/data,*.pyc,README.rst,pyproject-codespell.precommit-toml"
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:
types: [published]
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

permissions:
contents: read
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.coverage
.venv
build
dist
ld
codespell.egg-info
*.pyc
*.orig
.cache/
.coverage.*
.mypy_cache/
.pytest_cache/
.ruff_cache/
Expand Down
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exclude: ^(\.[^/]*cache/.*)$
repos:
- repo: /~https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.17
rev: 0.7.21
hooks:
- id: mdformat
name: Format Markdown
Expand All @@ -26,10 +26,10 @@ repos:
hooks:
- id: rst-linter
- repo: /~https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: no-commit-to-branch
args: [--branch, master]
args: [--branch, main]
- id: check-yaml
args: [--unsafe]
- id: debug-statements
Expand All @@ -50,36 +50,36 @@ repos:
files: dictionary.*\.txt$|\.wordlist$
args: [--ignore-case]
- repo: /~https://github.com/adrienverge/yamllint.git
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
args:
- --no-warnings
- -d
- "{extends: relaxed, rules: {line-length: {max: 90}}}"
- repo: /~https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
rev: v0.8.6
hooks:
- id: ruff
- id: ruff-format
- repo: /~https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
- repo: /~https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]
additional_dependencies:
- tomli
- repo: /~https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.23
hooks:
- id: validate-pyproject
- repo: /~https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.14.1
hooks:
- id: mypy
args: ["--config-file", "pyproject.toml"]
Expand Down
72 changes: 55 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ 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``.
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:

Expand All @@ -135,12 +135,34 @@ The words to ignore can be passed in two ways:
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:

.. code-block:: python
def wrod() # codespell:ignore wrod
pass
2. ignore multiple words:

.. code-block:: python
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
When running ``codespell``, it will check in the current directory for an
`INI file <https://en.wikipedia.org/wiki/INI_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:
Expand All @@ -152,15 +174,16 @@ be specified in this file (without the preceding dashes), for example:
count =
quiet-level = 3
The ``.codespellrc`` file is an `INI file <https://en.wikipedia.org/wiki/INI_file>`_,
which is read using Python's
`configparser <https://docs.python.org/3/library/configparser.html#supported-ini-file-structure>`_.
For example, comments are possible using ``;`` or ``#`` as the first character.
Python's
`configparser <https://docs.python.org/3/library/configparser.html#supported-ini-file-structure>`_
module defines the exact format of INI config files. 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:
file (or a file specified via ``--toml``), and the ``[tool.codespell]``
entry will be used. For versions of Python prior to 3.11, this requires
the tomli_ package. For example, here is the TOML equivalent of the
previous config file:

.. code-block:: toml
Expand All @@ -169,25 +192,40 @@ is installed for versions of Python prior to 3.11. For example:
count = true
quiet-level = 3
These are both equivalent to running:
The above INI and TOML files are equivalent to running:

.. code-block:: sh
codespell --quiet-level 3 --count --skip "*.po,*.ts,./src/3rdParty,./src/Test"
codespell --skip "*.po,*.ts,./src/3rdParty,./src/Test" --count --quiet-level 3
If several config files are present, they are read in the following order:

#. ``pyproject.toml`` (only if the ``tomli`` library is available)
#. ``pyproject.toml`` (only if the ``tomli`` library is available for Python < 3.11)
#. ``setup.cfg``
#. ``.codespellrc``
#. 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.
specified configurations. Any options specified in the command line will
*override* options from the config files.

Values in a config file entry cannot start with a ``-`` character, so if
you need to do this, structure your entries like this:

Any options specified in the command line will *override* options from the
config files.
.. code-block:: ini
[codespell]
dictionary = mydict,-
ignore-words-list = bar,-foo
instead of these invalid entries:

.. code-block:: ini
[codespell]
dictionary = -,mydict
ignore-words-list = -foo,bar
.. _tomli: https://pypi.org/project/tomli/

Expand Down Expand Up @@ -326,13 +364,13 @@ In the scenario where the user prefers not to follow the development version of

.. code-block:: sh
wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txt
wget https://raw.githubusercontent.com/codespell-project/codespell/main/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
/~https://github.com/codespell-project/codespell/tree/main/codespell_lib/data

License
-------
Expand Down
2 changes: 1 addition & 1 deletion codespell_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._codespell import _script_main, main
from ._version import __version__ # type: ignore[import-not-found]

__all__ = ["_script_main", "main", "__version__"]
__all__ = ["__version__", "_script_main", "main"]
5 changes: 1 addition & 4 deletions codespell_lib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
from ._codespell import _script_main

if __name__ == "__main__":
try:
sys.exit(_script_main())
except KeyboardInterrupt:
pass
sys.exit(_script_main())
Loading

0 comments on commit a0a08df

Please sign in to comment.