🐛 fix(config): substitute inside override values - #4048
Conversation
5e65e7a to
6ed5ba7
Compare
|
| and so does the That doesn't split the args either, it's only the default case that currently works when you pass a list. Currently we have:
|
9c0ba51 to
81d8a02
Compare
|
Within TOML the |
81d8a02 to
13c9a86
Compare
|
Rows 1 and 3 do not reproduce for me. The env_list = ["a"]
[env_run_base]
skip_install = true
commands = [["pytest", { replace = "posargs", extend = true }]]$ uvx --from 'tox==4.60.1' tox c -e a -k commands -- tests src
[testenv:a]
commands = pytest tests srcSame result with The three
The rule is that a list entry consisting of nothing but a posargs reference expands to one entry per argument. A reference embedded in a longer string ( |
1864b80 to
d616281
Compare
An override reaches tox as a raw command line string and was converted
straight to its target type, skipping the substitution pass every value
read from a configuration file goes through. `{posargs}`, `{env:VAR}`
and `{env_name}` therefore arrived as literal text, so
`-x env_run_base.commands='pytest {posargs}'` ran pytest against a
directory named `{posargs}`.
The loader that owns the value now expands the override with its own
replacer, so ini and TOML each keep their reference semantics. set_env
still expands later, matching how it is handled for file values.
d616281 to
a29655b
Compare
An override reaches tox as a raw command line string and never went through the substitution pass every value read from a configuration file goes through.
{posargs},{env:VAR}and{env_name}therefore arrived as literal text, sotox -x 'env_run_base.commands=pytest {posargs}' -- tests srcran pytest against a directory named{posargs}rather than forwarding the arguments. This hit--override,-xandTOX_OVERRIDE, in ini and TOML alike.An override now resolves the same substitutions a value in the configuration file would, and each format keeps its own reference syntax.
set_envis the exception: it expands late for file values too, and expanding it early would change how its self-references resolve.What an override may say is otherwise unchanged. tox still reads it with the ini string rules whatever the file format, which is what lets
-x env_run_base.commands=pytest testswork in a TOML project where the file spells commands as a list of lists.This is the part of the report that is a real defect. The
{ replace = "posargs", extend = true }table forwards positional arguments correctly on 4.60.1 today, and the"{posargs}"string form in a TOML list keeps resolving to one shell quoted argument, as documented.Fixes #4047