[tox]
minversion = 4.0
skipsdist = True

[common]
format_dirs = {toxinidir}/plugins {toxinidir}/tests

[testenv]
usedevelop = True
setenv = VIRTUAL_ENV={envdir}
         PYTHONHASHSEED=0
         PYTHONWARNINGS=default::DeprecationWarning
passenv = PYTHONPATH
install_command = pip install {opts} {packages}
deps = -r {toxinidir}/test-requirements.txt

[testenv:add_docs]
deps =
  git+https://github.com/ansible-network/collection_prep
commands =
  collection_prep_add_docs -p .

[testenv:antsibull-docs]
deps =
  aiohttp>=3.9.0b1 # required for python 3.12
  antsibull-docs
commands =
  antsibull-docs lint-collection-docs .

[testenv:black]
deps =
  black==23.12.1
commands =
  black --check --diff {[common]format_dirs}

[testenv:black_format]
deps =
  {[testenv:black]deps}
commands =
  black -v {[common]format_dirs}

[testenv:flake8]
deps =
  flake8
commands =
  flake8 {[common]format_dirs}

[testenv:isort]
deps =
  isort
commands =
  isort --check-only --diff {[common]format_dirs}

[testenv:isort_format]
deps =
  {[testenv:isort]deps}
commands =
  isort -v {[common]format_dirs}

[testenv:mypy]
allowlist_externals = bash
deps =
  mypy
  pytest
  pytest-forked
  pytest-mock
  pytest-xdist
  types-PyYAML
  packaging
  requests[security]
  xmltodict
setenv =
  {[testenv]setenv}
  MYPYPATH={toxinidir}
commands = bash {toxinidir}/run_mypy.sh

[testenv:format]
deps =
  {[testenv:black]deps}
  {[testenv:isort]deps}
commands =
  {[testenv:black]commands}
  {[testenv:isort]commands}

[testenv:linters]
allowlist_externals =
  {[testenv:mypy]allowlist_externals}
deps =
  {[testenv:antsibull-docs]deps}
  {[testenv:black]deps}
  {[testenv:flake8]deps}
  {[testenv:isort]deps}
  {[testenv:mypy]deps}
commands =
  {[testenv:antsibull-docs]commands}
  {[testenv:black]commands}
  {[testenv:flake8]commands}
  {[testenv:isort]commands}
  {[testenv:mypy]commands}

[flake8]
ignore = E402
max-line-length = 160
show-source = True
