🐛 fix(config): collapse continuation lines before factor filtering#3787
Merged
gaborbernat merged 2 commits intotox-dev:mainfrom Feb 20, 2026
Merged
🐛 fix(config): collapse continuation lines before factor filtering#3787gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat merged 2 commits intotox-dev:mainfrom
Conversation
…ox-dev#2912) Factor-specific multiline commands using backslash continuation no longer leak continuation lines into non-matching environments.
This was referenced Feb 20, 2026
gaborbernat
added a commit
that referenced
this pull request
Feb 20, 2026
Commit 78eb394 (#3787) moved continuation line collapsing (`\`) before factor filtering to fix #2912, where factor-specific multiline commands leaked continuation lines into non-matching environments. However, this broke the common pattern of using different factor prefixes on consecutive continuation lines — the collapsed single line caused prefixes like `!cov:` to be passed as literal command arguments instead of being filtered. ```ini commands = cov: coverage run \ !cov: python \ somefile.py ``` Running `tox -e py-cov` produced `coverage run '!cov:' python somefile.py` instead of `coverage run somefile.py`. The fix restores the original order (factor filter first, collapse `\` after) and makes `filter_for_env` continuation-aware. Two flags track whether a kept line has an active backslash chain (`active_continuation`) and whether a filtered-out line's continuation should be skipped (`pending_skip`). An unfactored continuation line is only dropped when it is exclusively reachable through removed factored lines, preserving the fix for #2912 while restoring the conditional continuation pattern from #3796. Fixes #3796.
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 factor-specific command uses backslash continuation (
\) to span multiple lines, the continuation lines leak into environments that don't match the factor. For example withfoo: python -c "\⏎ print('foo')", theprint('foo')"line gets executed as a standalone command in thebarenvironment becauseexpand_factors()sees it as an unfactored line.🔧 The root cause is the ordering of operations in
process_raw()— factor filtering viafilter_for_env()splits by newlines and evaluates each line independently, but backslash continuation collapsing (\\\nremoval) happened after filtering. Moving the continuation collapse to happen before factor filtering ensures multi-line commands are joined into a single line before the factor prefix check runs.This is an INI-only issue since TOML configs don't use
filter_for_env().Fixes #2912