Skip to content

dash vs. comma format in bracketed section names in .ini is either broken or needs better docs #3614

@zzzeek

Description

@zzzeek

Issue

in the docs, we see that there's a syntax we can use like this:

"Both enumerations ({1,2,3}) and numerical ranges ({1-3}) are supported, and can be mixed together:"
[tox]
env_list = py3{8-10, 11, 13-14}

wow! i never knew that. the dash part.

But that's in the env_list. Where is the specification for this format as used elsewhere? we see an example like this:

[testenv]
deps =
    py311,py310: urllib3
    py{311,310}-sqlite: mock

Can we use the dash format there too? Nope. The bug is, that every {} syntax should work everywhere (preferred!) or the docs need to really talk about what's allowed where and be very specific what's going on.

Below is an example of these syntaxes. It illustrates that while we can use py{39,310,311,312,313} just fine in a key, we cannot use py{39-313} - gets ignored silently. As a bonus, someone today also tried to use the {} nesting syntax that works for {env:} with the environment name tags, that doesnt work either.

Ive been listing out py{39,310,311} type things for many years, and it's tedious. It seems like tox by now should have gained some more flexibility with these things. Is this....better in TOML format ? is .ini the old way replaced by TOML ?

Example:

[tox]
envlist = py

[extras1]
deps=
    greenlet

[extras2]
deps=
    typing-extensions

[extras3]
deps=
    requests


[testenv]

deps=
     # a syntax that works.
    somespec-py{38,39,310,311,312,313,314}: {[extras1]deps}

     # can we use the dash syntax instead of listing out every version?
     # nope
    somespec-py{38-314}: {[extras2]deps}

     # can we nest inside these things?  nope, this syntax is not accepted
     # somespec-{py{312,313},otherspec}: {[extras3]deps}

allowlist_externals =
    sh

commands=
    sh -c echo  "hello world"

run this as:

$ tox -re somespec-py313 --notest

only greenlet gets installed. typing-extensions does not:

[classic@framework tmp]$ tox -re somespec-py313 --notest
somespec-py313: remove tox env folder /home/classic/tmp/.tox/somespec-py313
somespec-py313: install_deps> python -I -m pip install greenlet
  somespec-py313: OK (0.78 seconds)
  congratulations :) (0.81 seconds)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions