# This file is managed by 'repo_helper'.
# You may add new sections, but any changes made to the following sections will be lost:
#     * tox
#     * envlists
#     * testenv
#     * testenv:.package
#     * testenv:py313-dev
#     * testenv:py313
#     * testenv:py312-dev
#     * testenv:py312
#     * testenv:docs
#     * testenv:build
#     * testenv:lint
#     * testenv:perflint
#     * testenv:mypy
#     * testenv:pyup
#     * testenv:coverage
#     * flake8
#     * coverage:run
#     * coverage:report
#     * check-wheel-contents
#     * pytest

[tox]
envlist =
    py36
    py37
    py38
    py39
    py310
    py311
    py312
    py313-dev
    pypy36
    pypy37
    pypy38
    pypy39
    mypy
    build
skip_missing_interpreters = True
isolated_build = True
requires =
    pip>=21,!=22.2
    tox-envlist>=0.2.1
    tox~=3.0
    virtualenv!=20.16.0

[envlists]
test =
    py36
    py37
    py38
    py39
    py310
    py311
    py312
    py313-dev
    pypy36
    pypy37
    pypy38
    pypy39
qa = mypy, lint
cov = py38, coverage

[testenv]
setenv =
    PYTHONDEVMODE=1
    PIP_DISABLE_PIP_VERSION_CHECK=1
    SETUPTOOLS_USE_DISTUTILS=stdlib
deps = -r{toxinidir}/tests/requirements.txt
commands =
    python --version
    python -m pytest --cov=dom_toml -r aR tests/ {posargs}

[testenv:.package]
setenv =
    PYTHONDEVMODE=1
    PIP_DISABLE_PIP_VERSION_CHECK=1

[testenv:py313-dev]
download = True
setenv =
    PYTHONDEVMODE=1
    PIP_DISABLE_PIP_VERSION_CHECK=1
    UNSAFE_PYO3_SKIP_VERSION_CHECK=1

[testenv:py312]
download = True
setenv =
    PYTHONDEVMODE=1
    PIP_DISABLE_PIP_VERSION_CHECK=1

[testenv:docs]
setenv = SHOW_TODOS = 1
passenv = SPHINX_BUILDER
basepython = python3.8
changedir = {toxinidir}/doc-source
deps = -r{toxinidir}/doc-source/requirements.txt
commands = sphinx-build -M {env:SPHINX_BUILDER:html} . ./build {posargs}

[testenv:build]
setenv =
    PYTHONDEVMODE=1
    PIP_DISABLE_PIP_VERSION_CHECK=1
    PIP_PREFER_BINARY=1
    UNSAFE_PYO3_SKIP_VERSION_CHECK=1
skip_install = True
changedir = {toxinidir}
deps =
    build[virtualenv]>=0.3.1
    check-wheel-contents>=0.1.0
    twine>=3.2.0
    cryptography<40; implementation_name == "pypy" and python_version <= "3.7"
commands =
    python -m build --sdist --wheel "{toxinidir}"
    twine check dist/*.tar.gz dist/*.whl
    check-wheel-contents dist/

[testenv:lint]
basepython = python3.8
changedir = {toxinidir}
ignore_errors = True
skip_install = True
deps =
    flake8>=3.8.2,<5
    flake8-2020>=1.6.0
    flake8-builtins>=1.5.3
    flake8-docstrings>=1.5.0
    flake8-dunder-all>=0.1.1
    flake8-encodings>=0.1.0
    flake8-github-actions>=0.1.0
    flake8-noqa>=1.1.0,<=1.2.2
    flake8-pyi>=20.10.0,<=22.8.0
    flake8-pytest-style>=1.3.0,<2
    flake8-quotes>=3.3.0
    flake8-slots>=0.1.0
    flake8-sphinx-links>=0.0.4
    flake8-strftime>=0.1.1
    flake8-typing-imports>=1.10.0
    git+https://github.com/domdfcoding/flake8-rst-docstrings-sphinx.git
    git+https://github.com/domdfcoding/flake8-rst-docstrings.git
    git+https://github.com/python-formate/flake8-unused-arguments.git@magic-methods
    git+https://github.com/python-formate/flake8-missing-annotations.git
    pydocstyle>=6.0.0
    pygments>=2.7.1
    importlib_metadata<4.5.0; python_version<'3.8'
commands = python3 -m flake8_rst_docstrings_sphinx dom_toml tests --allow-toolbox {posargs}

[testenv:perflint]
basepython = python3.8
changedir = {toxinidir}
ignore_errors = True
skip_install = True
deps = perflint
commands = python3 -m perflint dom_toml {posargs}

[testenv:mypy]
basepython = python3.8
ignore_errors = True
changedir = {toxinidir}
deps =
    mypy==0.971
    -r{toxinidir}/tests/requirements.txt
    -r{toxinidir}/stubs.txt
commands = mypy dom_toml tests {posargs}

[testenv:pyup]
basepython = python3.8
skip_install = True
ignore_errors = True
changedir = {toxinidir}
deps = pyupgrade-directories
commands = pyup_dirs dom_toml tests --py36-plus --recursive

[testenv:coverage]
basepython = python3.8
skip_install = True
ignore_errors = True
whitelist_externals = /bin/bash
passenv =
    COV_PYTHON_VERSION
    COV_PLATFORM
    COV_PYTHON_IMPLEMENTATION
    *
changedir = {toxinidir}
deps =
    coverage>=5
    coverage_pyver_pragma>=0.2.1
commands =
    /bin/bash -c "rm -rf htmlcov"
    coverage html
    /bin/bash -c "DISPLAY=:0 firefox 'htmlcov/index.html'"

[flake8]
max-line-length = 120
select = E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E225 E226 E227 E228 E231 E241 E242 E251 E261 E262 E265 E271 E272 E303 E304 E306 E402 E502 E703 E711 E712 E713 E714 E721 W291 W292 W293 W391 W504 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001  PT001 PT002 PT003 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 ENC001 ENC002 ENC003 ENC004 ENC011 ENC012 ENC021 ENC022 ENC023 ENC024 ENC025 ENC026 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 NQA001 NQA002 NQA003 NQA004 NQA005 NQA102 NQA103 E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000  SLOT000 SLOT001 SLOT002
extend-exclude = doc-source,old,build,dist,__pkginfo__.py,setup.py,venv
rst-directives =
    TODO
    autoclasssumm
    autosummary-widths
    envvar
    extras-require
    license
    license-info
rst-roles = choosealicense
per-file-ignores =
    tests/*: D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000  SLOT000 SLOT001 SLOT002
    */*.pyi: E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000  SLOT000 SLOT001 SLOT002
pytest-parametrize-names-type = csv
inline-quotes = "
multiline-quotes = """
docstring-quotes = """
count = True
min_python_version = 3.6.1
unused-arguments-ignore-abstract-functions = True
unused-arguments-ignore-overload-functions = True
unused-arguments-ignore-magic-methods = True
unused-arguments-ignore-variadic-names = True

[coverage:run]
plugins = coverage_pyver_pragma

[coverage:report]
fail_under = 98.5
show_missing = True
exclude_lines =
    raise AssertionError
    raise NotImplementedError
    if 0:
    if False:
    if TYPE_CHECKING
    if typing.TYPE_CHECKING
    if __name__ == .__main__.:

[check-wheel-contents]
ignore = W002
toplevel = dom_toml
package = dom_toml

[pytest]
addopts = --color yes --durations 25
timeout = 300
filterwarnings =
    error
    ignore:can't resolve package from __spec__ or __package__, falling back on __name__ and __path__:ImportWarning
