1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
[tox]
min_version = 4
env_list =
pre-commit,
py3{8,9,10,11,12,13,14}-{tests,mypy}
py3{8,13}-tests-{colorama,be,rich},
typing-{mypy,pyright,ty,pyrefly},
docs-{sponsors,build,doctests},
coverage-{combine,report}
[testenv]
package = wheel
wheel_build_env = .pkg
dependency_groups =
tests: tests
mypy: typing
commands =
tests: pytest {posargs}
mypy: mypy tests/typing
# Run oldest and latest under Coverage.
# Keep in-sync with coverage `depends below.
[testenv:py3{8,13}-tests{,-colorama,-be,-rich}]
deps =
coverage[toml]
py313: twisted
colorama: colorama
rich: rich
be: better-exceptions
commands = coverage run -m pytest {posargs}
# Split combine/report in 2 to avoid excessive "Combined data file ..." output.
[testenv:coverage-combine]
# Keep base_python in-sync with .python-version-default
base_python = py313
# Keep in-sync with test env definition above.
depends = py3{8,13}-tests{,-colorama,-be,-rich}
skip_install = true
deps = coverage
commands = coverage combine
[testenv:coverage-report]
# Keep base_python in-sync with .python-version-default
base_python = py313
depends = coverage-combine
parallel_show_output = true
skip_install = true
deps = coverage
commands = coverage report
[testenv:docs-{build,doctests,linkcheck}]
# Keep base_python in sync with ci.yml/docs and .readthedocs.yaml.
base_python = py313
dependency_groups = docs
commands =
# N.B. doctests is not a nitpicky as build -- we need to run both in CI!
build: sphinx-build -n -T -W -b html -d {envtmpdir}/doctrees docs {posargs:docs/_build/}html
doctests: sphinx-build -n -T -W -b doctest -d {envtmpdir}/doctrees docs {posargs:docs/_build/}html
linkcheck: sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs docs/_build/html
[testenv:docs-watch]
package = editable
base_python = {[testenv:docs-build]base_python}
dependency_groups = {[testenv:docs-build]dependency_groups}
deps = watchfiles
commands =
watchfiles \
--ignore-paths docs/_build/ \
'sphinx-build -W -n --jobs auto -b html -d {envtmpdir}/doctrees docs docs/_build/html' \
src \
docs
[testenv:docs-sponsors]
description = Ensure sponsor logos are up to date.
deps = cogapp
commands = cog -rP README.md docs/index.md
[testenv:pre-commit]
skip_install = true
deps = prek
commands = prek run --all-files
[testenv:typing-{pyright,ty,mypy,pyrefly}]
description = Type-check the package.
# Keep base_python in-sync with .python-version-default
base_python = py313
dependency_groups = typing
deps =
pyrefly: pyrefly
pyright: pyright
ty: ty
commands =
# Mypy API checks need to happen per-Python version.
mypy: mypy src
pyrefly: pyrefly check
pyright: pyright tests/typing
ty: ty check
[testenv:color-force]
help = A visual check that FORCE_COLOR is working.
set_env = FORCE_COLOR=1
commands = python -c "import structlog; structlog.get_logger().warning('should be colorful')"
[testenv:color-no]
help = A visual check that NO_COLOR is working.
set_env = NO_COLOR=1
commands = python -c "import structlog; structlog.get_logger().warning('should be plain')"
[testenv:docset]
deps = doc2dash
dependency_groups = docs
allowlist_externals =
rm
cp
tar
commands =
rm -rf structlog.docset structlog.tgz docs/_build
sphinx-build -n -T -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
doc2dash --index-page index.html --icon docs/_static/docset-icon.png --icon-2x docs/_static/docset-icon@2x.png --online-redirect-url https://www.structlog.org/en/latest/ docs/_build/html
tar --exclude='.DS_Store' -cvzf structlog.tgz structlog.docset
|