-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow substitution from the current config section #1702
Comments
Note my PR doesnt even contemplate how to represent complex values like |
This is the easiest to read, understand and reason about it: [testenv:current]
deps = distro
commands = pip install {[testenv:current]deps} All other forms require the user to know the internal syntax. We defined how to resolve it. I'm personally -0.5 introducing a syntax just for these because:
I find needing to refer to the current section rarely enough to qualify the reference fully is not cumbersome. PS. Your example is not valid because you should not need to pip install |
The examples I gave are contrived, only for the purpose of showing inheritance. I should have used One problem with explicit literal "current" is [testenv]
deps = distro
[testenv:current]
commands = echo {[testenv:current]deps}
That might be solvable by adding inheritance/fallback-sections to the "other section" resolution. Happy to explore that if you see that as a useful approach. It does seem bug-ish that "other section" resolution doesnt respect testenv inheritance/fallback-sections, and there is no backwards incompatibility possible for implementing it.
|
Yeah, this one. I think I have this functionality work on the rewrite branch.
I think we can do this without significant performance hits, once we optimize things a bit. |
Does edit: related: #1822 |
This now has been implemented in the rewrite branch. I don't think we plan to support this feature on tox 3. |
Closing as has been fixed on the rewrite branch. |
The substitution engine allows access to any key from another section using
{[section_name]key_name}
, however afaics there isnt a way to do the same for the current section. It is possible to access predefined substitution names which are often the same as key, such as{commands}
, however adhoc keys in the current section cant be accessed.Another odd side effect of this is that
{[testenv:other]deps}
works, but it is not possible to get the deps of the current section without repeating the current section name. e.g.A nice conceptual syntax would be
{[.]key_name}
, however.
is a valid section name. Personally I think that.
is a dumb section name, whereasfoo.bar
might reasonably be in use. So making.
by itself an illegal section name (or as the first char of the section name), especially if given a nice error, makes sense. I am wondering why.
is legal in_FACTOR_LINE_PATTERN
. There doesnt appear to be any special meaning for.
so perhaps there is a good reason for it to be valid in testenv names.If
.
is not acceptable, I propose some others{[:]key_name}
,{[testenv::]commands}
and{[:]commands}
does currently work. Despite being legal, section name:
is more obviously problematic than.
. There is a bit of syntax overlap as{:}
refers toos.pathsep
, however{
is invalid within any{..}
syntax, and there is no intersection of "ini format" andos.pathsep
, so it doesnt seem using{[:]..}
is going to be confusing. More importantly,testenv::
is an error invirtualenv
:{[]key_name}
, which currently internally becomes{[:]key_name}
! i.e.{[]commands}
does currently work, and it getscommands
from section:
. However,{[]foo}
is sort-of over-loading[]
, because[]
incommands
means{posargs}
.{[-]key_name}
, as-
andtestenv:-
is an even more stupid section name.{[-]commands]}
and{[testenv:-]commands]}
do work, andenvlist = -
does runtestenv:-
however it is obviously problematic due to factoring, and should probably be explicitly an error because it is very likely this will break in odd ways, if not now it could easily break due to very minor implementation changes in the future.{[!]key_name}
, as!
is "reserved" for factor negating, and is invalid in testenv names.{[!]commands]}
and{[testenv:!]commands]}
do work, andenvlist = !
does runtestenv:!
however it is obviously problematic due to factoring, and should probably be explicitly an error because it is very likely this will break in odd ways, if not now it could easily break due to very minor implementation changes in the future. However using!
to refer to the current section feels illogical.{[#]key_name}
, as#
is sort-of reserved as a comment char in some contexts,envlist=#
doesnt work, and[#]
and[testenv:#]
appears to causeiniformat
parsing problems.{[#]foo}
doesnt immediately seem intuitive, but#
has a history of referring to sections/anchors, and without a suffix isnt pointing to a different section, so it isnt much of a stretch to use it to refer to the current section.{[,]key_name}
, astestenv:,
is also invalid, as it resolves to an empty string, and{[,]commands}
is also invalid (max-recursion!), and so is{[testenv:,]commands}
("substitution key '[testenv' not found" :/ ) , but{[,]key_name}
is ugly - it doesnt make any sense.Of the above, (2)
{[]key_name}
is my preference, because it currently works, but works in an unexpected way, so giving it a new sane meaning also fixes a bug at the same time.I also like (5)
{[#]key_name}
because it is the only symbol which is completely unusable currently in any related context, and has a very strong meaning (comment) in most contexts and is quite hard to make it valid in any context, e.g. file paths (#763.*
is another symbol which is illegal in some contexts as it is used for globbing. Globbing appears to be occurring indeps
,passenv
,allowlist_externals
,TOX_SKIP_ENV
, possibly alsoTOXENV
.In addition, using
{[*]foo}
to refer to the current section is even more illogical than using,
. Also[testenv:*]
and "[.*]
pattern to denote positional arguments with defaults" are mentioned in docs config.html .|
is used only in the v3.20+file|
. It doesnt seem appropriate to use{[|]key_name}
, and I suspect|
will grow more meaning over time.There are many other symbols which could be used instead of the above, but they will very likely be currently valid in section names, albeit probably not usable in
envlist
. e.g. within ascii, std keyboard+
,?
,^
,%
,$
,@
,&
, and backtick. It appears(
and)
are also unused so far, however those and=
,~
,<
and>
are commonly used indeps
pip syntax, so is;
and@
(and,
and!
). In any case, none of them seem obviously desirable for referring to the current section.Semantically, "{[]foo}" should refer to the section where the resolution is occurring, not where it is defined. (because it is already possibly to explicitly refer to the section where it is defined) i.e. with
tox -e other
should installfoobar
, notdistro
.This would mean that
{[]deps}
provides the same result as the unimplemented{packages}
.The text was updated successfully, but these errors were encountered: