Skip to content

✨ feat(config): add env_base templates for TOML#3817

Merged
gaborbernat merged 3 commits intotox-dev:mainfrom
gaborbernat:feature/env-base-templates
Feb 24, 2026
Merged

✨ feat(config): add env_base templates for TOML#3817
gaborbernat merged 3 commits intotox-dev:mainfrom
gaborbernat:feature/env-base-templates

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

Creating multiple TOML environments that share configuration (deps, commands, base_python) currently requires repeating those settings in every [env.X] section, or using a shared base that still appears as a runnable environment. This becomes painful when testing across a matrix of Python versions and framework versions.

env_base introduces named templates with a factors key that generates concrete environments via Cartesian product. A single [env_base.django] section with factors = [["py312", "py313"], ["django42", "django50"]] produces four environments, each inheriting the template's settings and resolving factor.X conditions independently. ✨ The inheritance chain is [env.{name}] > [env_base.{template}] > [env_run_base], so explicit per-environment overrides remain possible while eliminating repetition.

Factor groups support plain string lists, range dicts ({ prefix = "py3", start = 12, stop = 14 }), and mixtures of both for Cartesian products. Template names themselves never appear as runnable environments -- only the generated names show up in tox list and can be executed. Missing or malformed factors keys produce clear error messages directing users to [env.X] for single environments.

Creating multiple environments that share configuration required
repeating settings across individual [env.X] sections. env_base
introduces named templates with a factors key that generates
environments via Cartesian product, inheriting all template settings.

The inheritance chain resolves as env.{name} > env_base.{template} >
env_run_base, keeping explicit overrides possible while eliminating
repetition for environment matrices.
@gaborbernat gaborbernat force-pushed the feature/env-base-templates branch from 43c0d83 to b11394b Compare February 24, 2026 16:11
Use Unicode → instead of undefined RST |rarr| substitution in
config.rst, and move changelog fragment to flat naming convention
expected by pre-commit hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gaborbernat gaborbernat force-pushed the feature/env-base-templates branch from a1cbcb4 to 48748b2 Compare February 24, 2026 16:46
@gaborbernat gaborbernat enabled auto-merge (squash) February 24, 2026 17:11
@gaborbernat gaborbernat merged commit 8514045 into tox-dev:main Feb 24, 2026
51 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant