Skip to content

🔧 chore(tox): migrate tox.ini to tox.toml#3050

Merged
gaborbernat merged 4 commits into
mainfrom
migrate-tox-toml
Feb 19, 2026
Merged

🔧 chore(tox): migrate tox.ini to tox.toml#3050
gaborbernat merged 4 commits into
mainfrom
migrate-tox-toml

Conversation

@gaborbernat

Copy link
Copy Markdown
Contributor

The tox ecosystem has moved to native TOML configuration as the preferred format. This migrates tox.ini to tox.toml and switches the pre-commit hook from tox-ini-fmt to tox-toml-fmt v1.7.0 to match. 🔧

The generated tox.toml has been formatted with tox-toml-fmt to ensure it follows the canonical style.

@gaborbernat gaborbernat force-pushed the migrate-tox-toml branch 2 times, most recently from 6c5a390 to ff2a078 Compare February 18, 2026 06:48
gaborbernat added a commit to tox-dev/tox that referenced this pull request Feb 18, 2026
Using substitutions like `{env_site_packages_dir}` inside `set_env` in
TOML format causes a `RecursionError` because the TOML loader eagerly
resolves all string substitutions via `Unroll` before constructing
`SetEnv`. This creates a circular dependency: `set_env` →
`env_site_packages_dir` → `create_python_env()` → `system_site_packages`
→ `environment_variables` → `set_env`.

The INI loader already handles this correctly by detecting `SetEnv` type
and deferring string substitution — raw strings are stored as-is and
only resolved when individual env vars are accessed via `SetEnv.load()`.
🔧 This applies the same pattern to the TOML loader: structural TOML
constructs (`replace: ref`, `replace: posargs`, `replace: env`) are
still resolved during config loading, but string-level `{...}`
substitutions are deferred via a proper TOML-aware replacer passed to
`SetEnv.use_replacer()`.

Discovered via pypa/virtualenv#3050 when migrating virtualenv's config
from `tox.ini` to `tox.toml`. The same configuration that worked in INI
format caused infinite recursion in TOML because of the eager
substitution.

Closes #3758
The tox ecosystem has moved to native TOML configuration. Switch from
the legacy INI format and update the pre-commit hook from tox-ini-fmt
to tox-toml-fmt v1.7.0.
Fixes quoted env key handling — keys like "3.13t" are now
correctly expanded into separate table sections.
3.13t and 3.14t are Python version specifications, not custom
environments. These sections only contained env var overrides and
were conflicting with tox's version resolution. Removing them allows
tox to treat them as plain version specs.
@gaborbernat gaborbernat merged commit c5240c7 into main Feb 19, 2026
57 checks passed
@gaborbernat gaborbernat deleted the migrate-tox-toml branch February 19, 2026 00:21
gaborbernat added a commit to gaborbernat/virtualenv that referenced this pull request Feb 23, 2026
The tox.ini to tox.toml migration in pypa#3050 didn't update the sdist
include list, so tox.toml was missing from published packages.

Fixes pypa#3060
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant