Skip to content

✨ feat(toml): declare factor group defaults and per-run overrides - #4050

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:feat-factor-group-default
Aug 28, 2026
Merged

✨ feat(toml): declare factor group defaults and per-run overrides#4050
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:feat-factor-group-default

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Aug 28, 2026

Copy link
Copy Markdown
Member

#4045 asks for two things: a default for a labelled factor group, so {factor:label} does not need {factor:label:fallback} spelled out at every use site, and a way to run the matrix against a value it does not list, sketched there as tox -f "django_version:'==6.0'" or TOX_F_django_version.

The default half becomes a table form for a labelled group, carrying either values or a range alongside default: { django_version = { values = ["django42", "django50"], default = "django50" } }. The default has to be one of the group's own factors, which is checked at load, so it can never resolve to a name no environment produces. It applies when no factor of the group is active in the current environment name, and a {factor:label:fallback} at the use site still wins over it.

The injection half arrives as TOX_FACTOR_<label>, read for labels the configuration declares. env TOX_FACTOR_django_version=django61 tox run -e django-py314-django50 runs the environment the matrix generated while {factor:django_version} resolves to django61. The literal syntax from the issue, a version specifier passed through -f, does not work in tox's model, since labelled factor values are environment-name components and >=4.2,<4.3 cannot be one. Keeping the override out of the name sidesteps that, at the cost that the environment name no longer tells the whole story of a run.

Closes #4045

@gaborbernat gaborbernat added feature:new something does not exist yet, but should area:configuration labels Aug 28, 2026
@gaborbernat
gaborbernat force-pushed the feat-factor-group-default branch 5 times, most recently from 1484987 to 44e2dc6 Compare August 28, 2026 18:20
A labeled factor group only existed as a bare list of values, so
{factor:label} had no answer outside the generated matrix and every use
site had to repeat {factor:label:fallback} to get one. Nothing let a run
try a value the matrix does not list either, which is what a one-off
check against a new dependency release needs.

A group can now be spelled as a table carrying `values` or a range plus
`default`, so the fallback lives with the declaration and is validated
against the group's own factors. TOX_FACTOR_<label> resolves a declared
label for one run without touching env names, keeping factor values
inside the naming scheme they belong to.

The label map now holds a FactorGroup rather than a bare list, so a
group's factors and its default travel together.
@gaborbernat
gaborbernat force-pushed the feat-factor-group-default branch from 44e2dc6 to 374ed2e Compare August 28, 2026 19:56
@gaborbernat
gaborbernat marked this pull request as ready for review August 28, 2026 19:58
@gaborbernat
gaborbernat enabled auto-merge (squash) August 28, 2026 19:59
@gaborbernat
gaborbernat merged commit 8ef0326 into tox-dev:main Aug 28, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

env_base.factors: Get labelled factors from enviroment or factor cli argument

1 participant