🐛 fix(env): reject partial testenv section matches#3753
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Feb 18, 2026
Merged
🐛 fix(env): reject partial testenv section matches#3753gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat merged 1 commit intotox-dev:mainfrom
Conversation
Previously, `_ensure_envs_valid` decomposed all known env names
(including section headers like `functional-py310`) into individual
factors, making them freely combinable. This meant `tox -e
functional-py312` would silently pass validation and fall back to
the base testenv, even though only `functional{-py310}` was defined.
The fix distinguishes between combinable factors (from env_list and
conditional markers) and fixed env names from section headers. Section
names are accepted as whole identifiers but their component parts
can no longer be freely recombined with arbitrary factors.
Fixes tox-dev#3219
This was referenced Feb 19, 2026
|
Hello ! First, let me thank you for providing such powerful tool. It has greatly helped simplifying CI in pyvista It seems that this PR now prevents using complex factor conditions as described in https://tox.wiki/en/3.27.1/config.html#complex-factor-conditions Here is MWE with the behavior changes induced by this PR: [tox]
env_list = py3.{10-14}
[testenv]
deps =
matplotlib
np: numpy
np-cov: coverage
We managed to find a workaround in pyvista/pyvista#8343 by explicitly declaring factors but I was curious if this behavior change introduced by this PR was intentional. Thanks in advance. |
gaborbernat
added a commit
to gaborbernat/tox
that referenced
this pull request
Feb 20, 2026
PR tox-dev#3753 restricted env name validation to prevent section header names from being split into freely combinable factors. However, it also prevented factor-conditional-discovered env names (like `np-cov` from `np-cov: coverage`) from contributing their individual factors. This caused `tox -e py310-np-cov` to fail with "provided environments not found" when compound factor conditionals were used in the config. The fix distinguishes between section header env names (kept as whole identifiers) and factor-conditional env names (split into individual combinable factors), restoring the expected behavior. Fixes tox-dev#3780
gaborbernat
added a commit
to gaborbernat/tox
that referenced
this pull request
Feb 20, 2026
PR tox-dev#3753 restricted env name validation to prevent section header names from being split into freely combinable factors. However, it also prevented factor-conditional-discovered env names (like `np-cov` from `np-cov: coverage`) from contributing their individual factors. This caused `tox -e py310-np-cov` to fail with "provided environments not found" when compound factor conditionals were used in the config. The fix distinguishes between section header env names (kept as whole identifiers) and factor-conditional env names (split into individual combinable factors), restoring the expected behavior. Fixes tox-dev#3780
gaborbernat
added a commit
that referenced
this pull request
Feb 20, 2026
PR #3753 fixed section header names from being decomposed into freely combinable factors, preventing `tox -e functional-py312` from silently falling back to `[testenv]` when only `[testenv:functional{-py310}]` was defined. However, it also broke compound factor conditionals like `np-cov: coverage` — running `tox -e py310-np-cov` would fail with "provided environments not found" because the individual factor `cov` (from the compound conditional `np-cov`) was no longer recognized as combinable. 🔍 The fix distinguishes between env names from section headers and env names discovered from factor conditionals. Section header names remain valid only as whole identifiers (preserving the #3753 fix), while factor-conditional env names have their individual factors added to the combinable set. This is done by collecting section-derived env names via `Config.sections()` and treating everything else in `known_envs` (minus `env_list`) as factor-conditional — splitting those into individual factors. Fixes #3780
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.
When a testenv section uses generative syntax like
[testenv:functional{-py310}], onlyfunctional-py310should be a valid environment. However, runningtox -e functional-py312ortox -e functionalsilently passed validation and fell back to the base[testenv], producing unexpected results. 🔍 This was a regression from tox 3, where these would correctly error as unknown environments.The root cause was that
_ensure_envs_validdecomposed all known env names — including those from section headers — into individual factors, then treated them as freely combinable. Sofunctional(fromfunctional-py310) became a valid factor that could be mixed with any Python version factor. The fix distinguishes between factors that are genuinely combinable (fromenv_listgenerative expressions and conditional markers) and complete env names from section headers. Section names are recognized as whole identifiers but their component parts can no longer be arbitrarily recombined via-e.[testenv]will now get a clear error message pointing them to the correct environment name. Matrix-styleenv_listcombinations likepy312-django50continue to work as expected.Fixes #3219