diff --git a/.coveragerc b/.coveragerc index 09fee0e09a..f79450205d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -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 diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index c50416f6d0..289004d6fd 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -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" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 90daf602fc..57e77df58e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: diff --git a/AGENTS.md b/AGENTS.md index ef2d8e60c0..295160d0e5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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. @@ -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 @@ -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: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 90c44a95a9..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,11 +0,0 @@ -exclude *.yml -exclude .coveragerc -exclude .git-blame-ignore-revs -prune example -prune snap -prune .devcontainer -prune .github -exclude .gitignore -exclude .mailmap -exclude codespell.1.include -exclude pyproject-codespell.precommit-toml diff --git a/Makefile b/Makefile index c7560182b3..abdd0b6ede 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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; \ diff --git a/pyproject-codespell.precommit-toml b/pyproject-codespell.precommit-toml index e27bdc52de..ea9335d495 100644 --- a/pyproject-codespell.precommit-toml +++ b/pyproject-codespell.precommit-toml @@ -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/*" diff --git a/pyproject.toml b/pyproject.toml index ae3a03edbc..fa2840ecac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 @@ -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"] @@ -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",] diff --git a/codespell_lib/tests/__init__.py b/tests/__init__.py similarity index 100% rename from codespell_lib/tests/__init__.py rename to tests/__init__.py diff --git a/codespell_lib/tests/data/en_GB-additional.wordlist b/tests/data/en_GB-additional.wordlist similarity index 100% rename from codespell_lib/tests/data/en_GB-additional.wordlist rename to tests/data/en_GB-additional.wordlist diff --git a/codespell_lib/tests/data/en_US-additional.wordlist b/tests/data/en_US-additional.wordlist similarity index 100% rename from codespell_lib/tests/data/en_US-additional.wordlist rename to tests/data/en_US-additional.wordlist diff --git a/codespell_lib/tests/test_basic.py b/tests/test_basic.py similarity index 100% rename from codespell_lib/tests/test_basic.py rename to tests/test_basic.py diff --git a/codespell_lib/tests/test_dictionary.py b/tests/test_dictionary.py similarity index 98% rename from codespell_lib/tests/test_dictionary.py rename to tests/test_dictionary.py index 4411c49225..e105507d51 100644 --- a/codespell_lib/tests/test_dictionary.py +++ b/tests/test_dictionary.py @@ -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 @@ -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: diff --git a/tox.ini b/tox.ini index b93be53014..c350e39d58 100644 --- a/tox.ini +++ b/tox.ini @@ -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