Skip to content
/ tox Public
  • Sponsor tox-dev/tox

  • Notifications You must be signed in to change notification settings
  • Fork 531
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

feat(config): Allow ranges in envlist #3503

Merged
merged 7 commits into from
Mar 27, 2025

Conversation

mimre25
Copy link
Contributor

@mimre25 mimre25 commented Mar 21, 2025

Implements #3502. Now it is possible to use ranges within the {} of an env specifier such as py3{10-13}.
I chose to implement it as a pre-processing string replacement that just replaces the range with a literal enumeration of the range members. This is mainly to avoid more in-depth handling of these ranges when it coto generative environment lists.

Also moves CircularChainError from of_type to types to avoid a circular import error. (kinda ironic :D)

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

I hope my changes are fully backwards compatible - I added tests with all kind of combinations of generative environments - please let me know if you have some more test case suggestions 🙂

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
mimre25 Martin Imre
Implements tox-dev#3502. Now it is possible to use ranges within the {} of an
env specifier such as py3{10-13}.
I chose to implement it as a pre-processing string replacement that just
replaces the range with a literal enumeration of the range members.
This is mainly to avoid more in-depth handling of these ranges when it
coto generative environment lists.

Also moves CircularChainError from `of_type` to `types` to avoid a
circular import error. (kinda ironic :D)
@mimre25 mimre25 force-pushed the allow-ranges-in-env-list branch from 40c9d2d to 310255e Compare March 21, 2025 09:14
@mimre25
Copy link
Contributor Author

mimre25 commented Mar 21, 2025

When I run tox -e docs I get warnings a few <unknown>:1: WARNING: py:class reference target not found: typing.Self [ref.class], which don't seem to happen in the CI.

tox -e docs output
(tox) ➜  tox git:(allow-ranges-in-env-list) ✗ tox -e docs
.pkg: _optional_hooks> python /home/martin/micromamba/envs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_wheel> python /home/martin/micromamba/envs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_editable> python /home/martin/micromamba/envs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: build_wheel> python /home/martin/micromamba/envs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
docs: install_package> python -I -m pip install --force-reinstall --no-deps /home/martin/workspace/tox/.tox/.tmp/package/6/tox-4.24.3.dev4+g310255e0-py3-none-any.whl
docs: commands[0]> sphinx-build -d /home/martin/workspace/tox/.tox/docs/tmp/docs_tree docs /home/martin/workspace/tox/.tox/docs_out/html --color -b html -W
Running Sphinx v8.1.3
loading translations [en]... done
Converting `source_suffix = '.rst'` to `source_suffix = {'.rst': 'restructuredtext'}`.
loading intersphinx inventory 'python' from https://docs.python.org/3/objects.inv ...
loading intersphinx inventory 'packaging' from https://packaging.pypa.io/en/latest/objects.inv ...
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 11 source files that are out of date
updating environment: [new config] 11 added, 0 changed, 0 removed
reading sources... [100%] user_guide
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets...
copying static files...
Writing evaluated template result to /home/martin/workspace/tox/.tox/docs_out/html/_static/basic.css
Writing evaluated template result to /home/martin/workspace/tox/.tox/docs_out/html/_static/documentation_options.js
Writing evaluated template result to /home/martin/workspace/tox/.tox/docs_out/html/_static/language_data.js
Writing evaluated template result to /home/martin/workspace/tox/.tox/docs_out/html/_static/copybutton.js
copying static files: done
copying extra files...
copying extra files: done
copying assets: done
writing output... [100%] user_guide
<unknown>:1: WARNING: py:class reference target not found: typing.Self [ref.class]
<unknown>:1: WARNING: py:class reference target not found: typing.Self [ref.class]
<unknown>:1: WARNING: py:class reference target not found: typing.Self [ref.class]
generating indices... genindex py-modindex done
writing additional pages... search done
copying images... [100%] img/overview_dark.svg
dumping search index in English (code: en)... done
dumping object inventory... done
build finished with problems, 3 warnings (with warnings treated as errors).
docs: exit 1 (7.11 seconds) /home/martin/workspace/tox> sphinx-build -d /home/martin/workspace/tox/.tox/docs/tmp/docs_tree docs /home/martin/workspace/tox/.tox/docs_out/html --color -b html -W pid=67962
.pkg: _exit> python /home/martin/micromamba/envs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
  docs: FAIL code 1 (8.00=setup[0.88]+cmd[7.11] seconds)
  evaluation failed :( (8.07 seconds)

@mimre25
Copy link
Contributor Author

mimre25 commented Mar 21, 2025

I've noticed that the sponorlink (tidelift.com/funding/github/pypi/tox) doesn't seem to link to a funding page, but rather a general sales page of tidelift - is this indented?

@mimre25 mimre25 marked this pull request as ready for review March 21, 2025 09:31
@mimre25 mimre25 requested a review from gaborbernat as a code owner March 21, 2025 09:31
@pytest.mark.parametrize(
("env_list", "expected_envs"),
[
("py3{10-13}", ["py310", "py311", "py312", "py313"]),
Copy link
Member

@gaborbernat gaborbernat Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to see tests for the case when:

  • a-b
  • 8-b
  • a-9
  • a-
  • -b

Also, what about:

  • 9-7 ? Should we expand it or accept it? My initial thought is to expand it.

These cases should still be accepted, but not expanded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that the sponorlink (tidelift.com/funding/github/pypi/tox) doesn't seem to link to a funding page, but rather a general sales page of tidelift - is this indented?

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both 11- and a- run into a ValueError in the factor computations (I used foo{11-} and foo{a-}).
I'll take a look at fixing that.

On that note: This feature introduces syntax in the ini file that is not backwards compatible - should we be concerned about this?

9-7 ? Should we expand it or accept it? My initial thought is to expand it.

The current implementation expands it to 9,8,7.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm happy with expansion.

mimre25 and others added 3 commits March 23, 2025 14:10

Verified

This commit was signed with the committer’s verified signature.
mimre25 Martin Imre

Verified

This commit was signed with the committer’s verified signature.
mimre25 Martin Imre
for more information, see https://pre-commit.ci
@mimre25 mimre25 requested a review from gaborbernat March 23, 2025 18:24
mimre25 added 2 commits March 27, 2025 09:17

Verified

This commit was signed with the committer’s verified signature.
mimre25 Martin Imre

Verified

This commit was signed with the committer’s verified signature.
mimre25 Martin Imre
@mimre25 mimre25 requested a review from gaborbernat March 27, 2025 08:40

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@gaborbernat gaborbernat merged commit 0e6b4ad into tox-dev:main Mar 27, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants