[tox]
env_list =
    coverage_erase
    # When updating the list of Python versions to test,
    # use search-and-replace to ensure that intra-environment
    # dependencies are maintained for parallel execution.
    py{3.15, 3.14, 3.13, 3.12, 3.11}
    coverage_report
    mypy


[testenv:coverage_erase]
description = Erase coverage files
dependency_groups =
    dev
commands =
    coverage erase


[testenv]
runner = uv-venv-lock-runner
dependency_groups =
    dev
depends =
    py{3.15, 3.14, 3.13, 3.12, 3.11}: coverage_erase
commands =
    coverage run -m pytest tests/unit/ -s


[testenv:coverage_report{,-ci}]
description = Create a coverage report
depends =
    py{3.15, 3.14, 3.13, 3.12, 3.11}
dependency_groups =
    dev
commands_pre =
    # `coverage combine` will fail if run twice in a row.
    # The '-' ignores failures.
    - coverage combine
 # Only write an HTML reports when NOT running in CI.
    # Also, ignore the exit code if coverage falls below the fail_under value.
    !ci: - coverage html
commands =
    coverage report --fail-under={env:COVERAGE_FAIL_UNDER:99}
commands_post =
    # Only write an XML report when running in CI.
    ci: coverage xml --fail-under={env:COVERAGE_FAIL_UNDER:99}


[testenv:lint]
description = Lint the project
skip_install = true
dependency_groups =
    dev
commands =
    mypy
    isort --profile hug --check --diff isort/ tests/ scripts/
    isort --profile hug --check --diff example_isort_formatting_plugin/
    isort --profile hug --check --diff example_isort_sorting_plugin/
    isort --profile hug --check --diff example_shared_isort_profile/
    flake8 isort/ tests/
    ruff check
    ruff format --check
    bandit -r isort/


[testenv:docs]
description = Build the documentation
skip_install = true
dependency_groups =
    docs
commands =
    sphinx-build --nitpicky --fail-on-warning --write-all --fresh-env --builder html docs docs/_build/html