Skip to content

🐛 fix(config): restore factor conditional continuations#3799

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:fix/3796-factor-conditional-continuation
Feb 20, 2026
Merged

🐛 fix(config): restore factor conditional continuations#3799
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:fix/3796-factor-conditional-continuation

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

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.

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.

…tox-dev#3796)

Commit 78eb394 moved continuation line collapsing before factor filtering
to fix tox-dev#2912, but this broke the common pattern of using different factor
prefixes on consecutive continuation lines (e.g. `cov: coverage run \` /
`!cov: python \` / `somefile.py`). The collapsed single line caused factor
prefixes to be passed as literal command arguments.

Restore the original order (filter first, collapse after) and make
filter_for_env continuation-aware instead. Two flags track whether a kept
line has an active backslash chain and whether a filtered-out line is
pending skip, so unfactored continuations are only dropped when exclusively
reachable through removed factored lines. This fixes both tox-dev#3796 and tox-dev#2912.
@gaborbernat gaborbernat added bug:normal affects many people or has quite an impact area:configuration labels Feb 20, 2026
@gaborbernat gaborbernat enabled auto-merge (squash) February 20, 2026 15:18
@gaborbernat gaborbernat merged commit 413b963 into tox-dev:main Feb 20, 2026
28 checks passed
gaborbernat added a commit to gaborbernat/tox that referenced this pull request Feb 20, 2026
…ors (tox-dev#3802)

The pending_skip logic from tox-dev#3799 was too aggressive: it skipped all
unfactored lines following a filtered factor-conditional continuation,
even when those lines were independent shared arguments (e.g. pytest,
--remote-data). Now only terminal continuation pieces are skipped,
while lines that are themselves continuations are preserved.
gaborbernat added a commit that referenced this pull request Feb 20, 2026
…ors (#3802) (#3804)

The continuation-aware factor filtering from #3799 was too aggressive
when skipping unfactored lines. In configs like the [asdf project's
tox.ini](https://github.com/asdf-format/asdf/blob/a50580d/tox.ini),
shared arguments such as `pytest \`, `--remote-data \`, and
`--durations=10 \` were being silently dropped whenever they followed a
filtered factor-conditional line ending with `\`. This caused commands
to lose most of their arguments for non-matching environments, breaking
CI.

The fix narrows the skip condition so that only terminal continuation
pieces (lines that don't themselves end with `\`) are dropped after a
filtered factor. Lines that are themselves continuations are preserved,
since they typically represent independent shared arguments rather than
exclusive content of the filtered line. The `active_continuation`
tracking is also corrected to recognize continuations initiated by
unfactored lines, not just factored ones.

This preserves the existing fixes for both #2912 (factor-specific
multiline commands) and #3796 (alternative factor continuations) while
restoring correct behavior for mixed factor/unfactored continuation
patterns.

Fixes #3802

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:configuration bot:chronographer:provided bug:normal affects many people or has quite an impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conditional part of commnads no works factor-specific commands broken with multiline

1 participant