Skip to content

🐛 fix(config): resolve factor labels by position when groups share a value - #4402

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
Kernel-Hunter:factor-label-shared-value
Nov 17, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
Kernel-Hunter:factor-label-shared-value

Conversation

@Kernel-Hunter

Copy link
Copy Markdown
Contributor

When two factor groups contain the same value, {factor:label} picks the wrong one. replace_factor checks each group's values against the set of factors in the env name, so the first value of the group that shows up anywhere in the name wins, whichever group put it there.

[env_base.migrate]
factors = [{ source = ["py312", "py313"] }, { target = ["py312", "py313"] }]
description = "{factor:source} to {factor:target}"

tox l showed migrate-py313-py312 -> py312 to py312 and migrate-py312-py313 -> py312 to py312. The same happens with labeled groups in an env_list product, e.g. { client = ["v1", "v2"] }, { server = ["v1", "v2"] }.

The env names are built from the cartesian product, so at that point we know which value each group contributed. The fix records that per generated env name on the FactorGroup and replace_factor uses it first. Envs outside the matrix (an [env.NAME] table, or an env_base label read from an env_list env) still go through the old membership lookup and the declared default.

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added a docs/changelog fragment for user-facing changes, or applied skip news
  • updated/extended the documentation
  • ran tests on Python 3.11 and 3.15 (tox run -e 3.11,3.15)
  • linked upstream issues beside any temporary interpreter overrides
  • kept the PR in draft until CI passes

@gaborbernat
gaborbernat force-pushed the factor-label-shared-value branch from c5ad374 to 75f67c6 Compare November 17, 2026 16:39
@gaborbernat gaborbernat added the bug A confirmed defect label Nov 17, 2026
@gaborbernat
gaborbernat merged commit b787bb9 into tox-dev:main Nov 17, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A confirmed defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants