Skip to content

🐛 fix(toml): extract args from Command in ref replacement#3863

Merged
gaborbernat merged 5 commits into
tox-dev:mainfrom
gaborbernat:fix-toml-command-ref
Mar 6, 2026
Merged

🐛 fix(toml): extract args from Command in ref replacement#3863
gaborbernat merged 5 commits into
tox-dev:mainfrom
gaborbernat:fix-toml-command-ref

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Mar 5, 2026

Copy link
Copy Markdown
Member

Plugin-registered Command values like list_dependencies_command couldn't be referenced using the structured {replace = "ref"} syntax in TOML configurations. 🐛 When trying to use {replace = "ref", env = "a", key = "list_dependencies_command"}, the replacement returned the Command object itself rather than its args list, causing type errors when integrating into commands = [[...]] which expects list[list[str]].

The fix modifies _replace_ref() to detect when the referenced value is a Command object and extract its .args list. ✨ This makes Command values compatible with TOML's structured list format and provides the proper TOML-native way to reference them, replacing the INI-ism of string interpolation like "{list_dependencies_command}" which stringifies the command into a single unparseable string.

Users can now reference Command-type configuration values in TOML using the structured replacement syntax with extend = true to spread the args into the command list.

Closes #3830

@gaborbernat gaborbernat added the bug:normal affects many people or has quite an impact label Mar 5, 2026
Plugin-registered Command values like list_dependencies_command couldn't be referenced using the structured {replace = "ref"} syntax in TOML because the replacement returned the Command object itself rather than its args list. This caused type errors when integrating into commands = [[...]] which expects list[list[str]].

Modified _replace_ref() to detect Command objects and extract their .args list, making them compatible with TOML's structured list format. This provides the proper TOML-native way to reference Command values, replacing the INI-ism of string interpolation like "{list_dependencies_command}" which stringify the command into a single string.

Fixes tox-dev#3830
@gaborbernat gaborbernat force-pushed the fix-toml-command-ref branch from e6621d5 to 69f53d0 Compare March 5, 2026 23:29
gaborbernat and others added 4 commits March 5, 2026 15:30
Added documentation explaining that Command-type configuration values like list_dependencies_command can be referenced using the structured {replace = "ref"} syntax in TOML. The reference automatically extracts the command's argument list for compatibility with TOML's list[list[str]] structure.

This documents the fix for tox-dev#3830 and provides users with the correct pattern to use instead of string interpolation which doesn't work for Command values in TOML.
Added documentation explaining that Command-type configuration values like list_dependencies_command can be referenced using the structured {replace = "ref"} syntax in TOML. The reference automatically extracts the command's argument list for compatibility with TOML's list[list[str]] structure.

This documents the fix for tox-dev#3830 and provides users with the correct pattern to use instead of string interpolation which doesn't work for Command values in TOML.
Document the fix for Command ref replacement in TOML configurations.
@gaborbernat gaborbernat enabled auto-merge (squash) March 5, 2026 23:38
@gaborbernat gaborbernat merged commit 113bcf8 into tox-dev:main Mar 6, 2026
50 of 51 checks passed
@gaborbernat gaborbernat deleted the fix-toml-command-ref branch March 6, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

list_dependencies_command doesn't seem to work with tox.toml

1 participant