✨ feat(config): add platform-dependent factor support#3779
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Feb 19, 2026
Merged
✨ feat(config): add platform-dependent factor support#3779gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat merged 1 commit intotox-dev:mainfrom
Conversation
3b3e25f to
b1db9b8
Compare
Users could not write platform-specific configuration without encoding the platform in environment names (e.g., py313-linux, py313-darwin). This forced duplication of environment definitions and made cross-platform projects harder to maintain. TOML users also lacked any way to use factor-based filtering, which was only available in INI configurations. Added automatic platform factor support by injecting sys.platform into the factor set for all environments. In INI, this enables inline factor syntax like "linux: pytest" or "!win32: uvloop". In TOML, extended conditional expressions (added in 4.40) to support factor.NAME lookups alongside env.VAR, enabling conditions like "factor.linux" or "factor.django50 and not env.CI". Both formats now have feature parity for factor-based configuration filtering, with platform automatically available as an implicit factor in any environment without requiring it in the environment name.
a21a3af to
d7ae712
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.
Managing cross-platform projects required creating separate test environments for each platform (like
task-linux,task-darwin,task-win32) or using theplatformconfiguration option which skips entire environments when the regex doesn't match. Neither approach allowed a single environment to run different commands based on the execution platform. 🔧This change injects
sys.platformas an implicit factor available to all environments. Platform values likelinux,darwin, andwin32become automatically available alongside factors from the environment name, enabling natural conditional configuration that adapts at runtime. Users can now writelinux: pytestorwin32: mypyin a single environment without encoding the platform in the environment name.The implementation adds one line to
filter_for_env()insrc/tox/config/loader/ini/factor.pyto includesys.platformin the factor set. This leverages the existing factor filtering infrastructure without requiring changes to how factors are parsed or matched. ✨Resolves #2092