🔧 chore(tox): migrate tox.ini to tox.toml#3050
Merged
Merged
Conversation
6c5a390 to
ff2a078
Compare
This was referenced Feb 18, 2026
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.
d590287 to
d6aa8e0
Compare
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.
This was referenced Mar 12, 2026
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tox ecosystem has moved to native TOML configuration as the preferred format. This migrates
tox.initotox.tomland switches the pre-commit hook fromtox-ini-fmttotox-toml-fmtv1.7.0 to match. 🔧The generated
tox.tomlhas been formatted withtox-toml-fmtto ensure it follows the canonical style.