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

Error with requires when using native TOML configuration #3386

Closed
daneah opened this issue Oct 2, 2024 · 1 comment · Fixed by #3388
Closed

Error with requires when using native TOML configuration #3386

daneah opened this issue Oct 2, 2024 · 1 comment · Fixed by #3388
Assignees
Labels
bug:normal affects many people or has quite an impact

Comments

@daneah
Copy link

daneah commented Oct 2, 2024

Issue

tox doesn't like the requires key when using (as documented) native TOML configuration.

Environment

Provide at least:

  • OS: macOS
Output of pip list of the host Python, where tox is installed
$ pipx runpip tox list
Package       Version
------------- -------
cachetools    5.5.0
chardet       5.2.0
colorama      0.4.6
distlib       0.3.7
filelock      3.16.1
packaging     24.1
pip           24.2
platformdirs  4.3.6
pluggy        1.5.0
pyproject-api 1.8.0
setuptools    69.0.2
tox           4.21.0
tox-uv        1.13.0
uv            0.4.18
virtualenv    20.26.6
wheel         0.42.0

Output of running tox

Output of tox -rvv
Traceback (most recent call last):
  File "/Users/dhillard/.local/bin/tox", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/run.py", line 20, in run
    result = main(sys.argv[1:] if args is None else args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/run.py", line 42, in main
    result = provision(state)
             ^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/provision.py", line 89, in provision
    requires: list[Requirement] = state.conf.core["requires"]
                                  ~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/sets.py", line 116, in __getitem__
    return self.load(item)
           ^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/sets.py", line 127, in load
    return config_definition.__call__(self._conf, self.loaders, ConfigLoadArgs(chain, self.name, self.env_name))  # noqa: PLC2801
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/of_type.py", line 109, in __call__
    value = loader.load(key, self.of_type, self.factory, conf, args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/api.py", line 148, in load
    converted = self.build(key, of_type, factory, conf, raw, args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/toml/__init__.py", line 66, in build
    return self.to(exploded, of_type, factory)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/convert.py", line 33, in to
    return self._to_typing(raw, of_type, factory)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/convert.py", line 60, in _to_typing
    result = [self.to(i, entry_type, factory) for i in self.to_list(raw, entry_type)]
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/toml/__init__.py", line 82, in to_list
    return iter(validate(value, of))  # type: ignore[call-overload,no-any-return]
                ^^^^^^^^^^^^^^^^^^^
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/toml/_validate.py", line 37, in validate
    validate(va, entry_type)
  File "/Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/config/loader/toml/_validate.py", line 69, in validate
    raise TypeError(msg)
TypeError: 'tox>=4.21.0' is not of type 'Requirement'

Minimal example

$ ls -a
.    ..    pyproject.toml
# pyproject.toml

[tool.tox]
requires = ["tox>=4.21.0"]
$ tox --version
4.21.0 from /Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox/__init__.py
registered plugins:
    tox-uv-1.13.0 at /Users/dhillard/.local/pipx/venvs/tox/lib/python3.11/site-packages/tox_uv/plugin.py with uv==0.4.18
@daneah daneah changed the title Error when using requires in native TOML configuration Error with requires when using native TOML configuration Oct 2, 2024
@gaborbernat gaborbernat self-assigned this Oct 2, 2024
@gaborbernat gaborbernat added the bug:normal affects many people or has quite an impact label Oct 2, 2024
@gaborbernat
Copy link
Member

This now has been fixed in 4.21.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants