[tox]
envlist =
    coverage-erase
    test-py{3.15, 3.14, 3.13, 3.12, 3.11, 3.10}
    coverage-report
    coverage-html
    build{, -minimum}
    mypy-py{3.15, 3.14, 3.13, 3.12, 3.11, 3.10}
    docs
labels =
    update = update-{pre_commit, requirements}

[testenv]
package = wheel
wheel_build_env = build_wheel
commands =
    python -c "import sys; sys.exit('This is not a runnable tox environment')"

[testenv:test-py{3.15, 3.14, 3.13, 3.12, 3.11, 3.10}]
description = Test the code on Python {py_dot_ver}
depends =
    coverage-erase
deps = -r requirements/test/requirements.txt
commands = coverage run -m pytest {posargs}

[testenv:mypy-py{3.15, 3.14, 3.13, 3.12, 3.11, 3.10}]
description = Test type annotations on Python {py_dot_ver}
deps = -r requirements/mypy/requirements.txt
setenv =
    MYPY_FORCE_COLOR=1
commands = mypy {posargs}

[testenv:coverage_base]
description = Base config for coverage-* environments
deps = -r requirements/test/requirements-coverage.txt
skip_install = true

[testenv:coverage-erase]
description = Erase coverage data files
base = coverage_base
commands =
    coverage erase

[testenv:coverage-report]
description = Display a coverage report and verify the fail-under value
base = coverage_base
depends = test-py{3.15, 3.14, 3.13, 3.12, 3.11, 3.10}
commands_pre =
    - coverage combine
commands =
    coverage report

[testenv:coverage-html]
description = Create an HTML coverage report
base = coverage_base
depends = test-py{3.15, 3.14, 3.13, 3.12, 3.11, 3.10}, coverage-report
commands =
    coverage html --fail-under=0

[testenv:docs]
description = Test building the documentation
base_python = py3.14
skip_install = true
deps = -r requirements/docs/requirements.txt
commands =
    sphinx-build -aWEnb html docs/ build/docs/

[testenv:build{, -minimum}]
description =
    Test building the project
    minimum: (minimum requirements)
base_python =
    minimum: py3.10
    !minimum: py3.14
skip_install = true
recreate = true
deps =
    build
    twine
    minimum: poetry-core==2.0.0
    !minimum: poetry-core<3.0.0
commands =
    python -m build --outdir {envdir}/dist/ --no-isolation
    twine check --strict {envdir}/dist/*

[testenv:update_base]
description = Base settings for update-* environments
base_python = py3.14
recreate = true
skip_install = true

[testenv:update-pre_commit]
description = Update pre-commit hooks
base = update_base
deps =
    prek
    upadup
commands =
    prek auto-update --cooldown-days 20 --freeze
    upadup

[testenv:update-requirements]
description = Update requirements files
base = update_base
deps =
    poetry
    poetry-plugin-export
commands =
    poetry update --directory="requirements/docs" --lock
    poetry export --directory="requirements/docs" --output="requirements.txt" --without-hashes
    poetry update --directory="requirements/mypy" --lock
    poetry export --directory="requirements/mypy" --output="requirements.txt" --without-hashes
    poetry update --directory="requirements/test" --lock
    poetry export --directory="requirements/test" --output="requirements.txt" --without-hashes
    poetry export --directory="requirements/test" --output="requirements-coverage.txt" --without-hashes --only="coverage"
