Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[run]
branch = True
source = codespell_lib
omit = */codespell_lib/tests/*
source = [ codespell_lib, tests ]
omit = */tests/*
# Some tests run the codespell entry point in a subprocess; without this their
# coverage is invisible (pytest-cov 7 dropped its own subprocess support).
patch = subprocess
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,./codespell_lib/tests/data,*.pyc,README.rst,pyproject-codespell.precommit-toml"
skip: "./.git,./codespell_lib/data,./example/code.c,test_basic.py,./tests/data,*.pyc,README.rst,pyproject-codespell.precommit-toml"
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ jobs:
# tomli should not be required for the next two steps (and make sure it's not)
- run: pip uninstall -yq tomli
if: ${{ matrix.kind == 'no-toml' }}
- run: codespell --check-filenames --skip="./.*,./build/*,./codespell_lib/data/*,./codespell_lib/tests/test_basic.py,./example/code.c,./junit-results.xml,*.egg-info/*,*.pyc,*.sig,pyproject-codespell.precommit-toml,README.rst,"
- run: codespell --check-filenames --skip="./.*,./build/*,./codespell_lib/data/*,./tests/test_basic.py,./example/code.c,./junit-results.xml,*.egg-info/*,*.pyc,*.sig,pyproject-codespell.precommit-toml,README.rst,"
# this file has an error
- run: "! codespell codespell_lib/tests/test_basic.py"
- run: "! codespell tests/test_basic.py"
shell: bash -e {0}

make-check-dictionaries:
Expand Down
15 changes: 7 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ when something actually needs it.
near-duplicate.
- **Do not add dependencies** without asking first.
- **Add to an existing test before writing a new one.** Extend a test in
`codespell_lib/tests/test_basic.py` that already sets up what you need,
then add a new test function there, and only then consider a new file. A
few compact assertions beat a long test that re-creates setup.
`tests/test_basic.py` that already sets up what you need, then add a new
test function there, and only then consider a new file. A few compact
assertions beat a long test that re-creates setup.
- **For a bug fix, confirm the test fails without the fix and passes with
it.** A regression test that passes without the fix guards nothing.

Expand All @@ -52,7 +52,7 @@ when something actually needs it.
```bash
pip install -e . --group dev # editable install with test/lint deps
pre-commit install --install-hooks # ruff, mypy, codespell, file sorting, ...
pytest codespell_lib/tests/test_basic.py -k write_changes # CLI tests
pytest tests/test_basic.py -k write_changes # CLI tests
make check-dictionaries # sort + validate dictionaries (test_dictionary.py)
pre-commit run --all-files # all linters, auto-fixing where possible
make check # everything CI checks: dictionaries, build, pytest, ruff
Expand All @@ -66,10 +66,9 @@ Pure Python (>= 3.9), no runtime dependencies.
file checking/fixing.
- `codespell_lib/data/dictionary*.txt`: the misspelling dictionaries, one
per `--builtin` set.
- `codespell_lib/tests/test_basic.py`: CLI behavior tests, mostly calling
`cs.main(...)` on files in `tmp_path`.
- `codespell_lib/tests/test_dictionary.py`: dictionary format and
consistency checks.
- `tests/test_basic.py`: CLI behavior tests, mostly calling `cs.main(...)`
on files in `tmp_path`.
- `tests/test_dictionary.py`: dictionary format and consistency checks.

Dictionary entries are `typo->fix`; with more than one fix, end the line
with a comma so none is applied automatically:
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DICTIONARIES = codespell_lib/data/dictionary*.txt codespell_lib/tests/data/*.wordlist
DICTIONARIES = codespell_lib/data/dictionary*.txt tests/data/*.wordlist

PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dist pytest pypi ruff clean

Expand All @@ -23,7 +23,7 @@ check-dictionaries: sort-dictionaries
fi; \
done
@if command -v pytest > /dev/null; then \
pytest codespell_lib/tests/test_dictionary.py; \
pytest tests/test_dictionary.py; \
else \
echo "Test dependencies not present, install using 'pip install -e . --group dev'"; \
exit 1; \
Expand Down
4 changes: 2 additions & 2 deletions pyproject-codespell.precommit-toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
builtin = "clear,rare,informal,usage,code,names"
#ignore-words-list = ["uint"]
ignore-words-list = "adn,master,uint,wrod"
#skip=[ "./.*","codespell_lib/data/*","codespell_lib/tests/*"]
skip="./.*,codespell_lib/data/*,codespell_lib/tests/*"
#skip=[ "./.*","codespell_lib/data/*","tests/*"]
skip="./.*,codespell_lib/data/*,tests/*"
18 changes: 11 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@ codespell = "codespell_lib:_script_main"
homepage = "https://github.com/codespell-project/codespell"
repository = "https://github.com/codespell-project/codespell"

[tool.flit.module]
name = "codespell_lib"

[tool.flit.sdist]
include = [
]

# flit_scm uses setuptools_scm under the hood to write the version file at
# build time, so that flit can stamp the version into the package metadata.
[tool.setuptools_scm]
write_to = "codespell_lib/_version.py"

[tool.flit.module]
name = "codespell_lib"

# TODO: reintegrate codespell configuration after updating test cases
#[tool.codespell]
#builtin = ["clear","rare","informal","usage","code","names"]
#ignore-words-list = ["uint"]
#skip=[ "./.*","codespell_lib/data/*","codespell_lib/tests/*"]
#skip=[ "./.*","codespell_lib/data/*","tests/*"]

[tool.mypy]
pretty = true
Expand All @@ -83,7 +87,7 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[tool.pytest.ini_options]
minversion = "6"
testpaths = ["codespell_lib/tests"]
testpaths = ["tests"]
log_cli_level = "INFO"
xfail_strict = true
addopts = ["--cov=codespell_lib", "-rs", "--strict-config", "--strict-markers", "--cov-report=", "--tb=short", "--junit-xml=junit-results.xml"]
Expand Down Expand Up @@ -150,8 +154,8 @@ max-complexity = 45

[tool.ruff.lint.per-file-ignores]
"codespell_lib/_codespell.py" = ["A003"]
"codespell_lib/tests/test_*" = ["S101"]
"codespell_lib/tests/test_basic.py" = ["ANN401", "N802"]
"tests/test_*" = ["S101"]
"tests/test_basic.py" = ["ANN401", "N802"]

[tool.ruff.lint.pylint]
allow-magic-value-types = ["bytes", "int", "str",]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
global_pairs: set[tuple[str, str]] = set()

# Filename, should be seen as errors in aspell or not
_data_dir = op.join(op.dirname(__file__), "..", "data")
_data_dir = op.join(op.dirname(__file__), "..", "codespell_lib", "data")
_fnames_in_aspell = [
(op.join(_data_dir, f"dictionary{d[2]}.txt"), d[3:5], d[5:7])
for d in _builtin_dictionaries
Expand Down Expand Up @@ -84,8 +84,8 @@ def test_dictionary_formatting(
@pytest.mark.parametrize(
"filename",
[
*(root / "data").rglob("dictionary*.txt"),
*(root / "tests/data").rglob("*.wordlist"),
*(root / "codespell_lib" / "data").rglob("dictionary*.txt"),
*(root / "tests" / "data").rglob("*.wordlist"),
],
)
def test_dictionary_sorting(filename: pathlib.Path) -> None:
Expand Down
5 changes: 0 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ commands = make check-dictionaries
description = run unit tests
dependency_groups = dev
commands = pytest --cov=codespell_lib {posargs} codespell_lib

[testenv:type]
description = run type checks
dependency_groups = types
commands = mypy codespell_lib
Loading