🐛 fix(toml): extract args from Command in ref replacement#3863
Merged
Conversation
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
e6621d5 to
69f53d0
Compare
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.
for more information, see https://pre-commit.ci
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.
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.
Plugin-registered Command values like
list_dependencies_commandcouldn'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 intocommands = [[...]]which expectslist[list[str]].The fix modifies
_replace_ref()to detect when the referenced value is a Command object and extract its.argslist. ✨ 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 = trueto spread the args into the command list.Closes #3830