🐛 fix(cli): make multiple -e flags additive#3755
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Feb 18, 2026
Merged
Conversation
cf5f28a to
44733aa
Compare
In tox 3, `tox -e a -e b` would run both environments. In tox 4 the second `-e` silently replaced the first, running only `b`. This broke CI pipelines that relied on the additive behavior. Replaced the default argparse store action with a custom action that accumulates values into the existing CliEnv via a new `__iadd__` method, so repeated `-e` flags merge their environment lists. Fixes tox-dev#3199
44733aa to
ad7e4ad
Compare
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.
In tox 3, running
tox -e a -e bwould execute both environments. In tox 4 the second-esilently replaced the first, so onlybwould run. 🔍 This broke CI pipelines and scripts that relied on the additive behavior, with no error or warning to indicate environments were being dropped.The fix uses a custom argparse action that accumulates values from repeated
-eflags into a singleCliEnvinstance instead of replacing it. This restores tox 3 behavior while preserving full backward compatibility —tox -e a,b(comma-separated) continues to work exactly as before.-eflags to override earlier ones will now get the union of all specified environments. The comma-separated formtox -e a,bremains the canonical way to specify multiple environments in a single flag.Fixes #3199