Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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 🙂

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.

@@ -287,9 +288,23 @@ def replace_tty(args: list[str]) -> str:
return (args[0] if len(args) > 0 else "") if sys.stdout.isatty() else args[1] if len(args) > 1 else ""


def expand_ranges(value: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

This should be alongside extend_factors, not here.

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.

2 participants