Skip to content

tox docs configuration results in an error #529

@MitchellAcoustics

Description

@MitchellAcoustics

Describe the Bug

Running tox -e docs locally or in the GH action for a new repo fails with TypeError: 'mkdocs' is not list

This seemed to be an error with the tool.tox setup in pyproject.toml. For me, it was solved using a nested list for the env.docs commands:

Broken:

[tool.tox]
env.docs = {commands = ["mkdocs", "build", "--strict"], extras = ["docs"]}

Fixed:

[tool.tox]
env.docs = {commands = [["mkdocs", "build", "--strict"]], extras = ["docs"]}

To Reproduce

uvx cookiecutter gh:ucl-arc/python-tooling --checkout latest
cd {repo_slug}
uv sync --all-extras
uv run tox -e docs

Expected Behaviour

Documentation is built using tox docs environment and exits successfully.

Actual Behaviour

Tox fails with following error:

❯ uv run tox -e docs
      Built satp-kit @ file:///Users/mitch/Documents/Code%20Projects/satp-kit
Uninstalled 1 package in 0.98ms
Installed 1 package in 1ms
.pkg: _optional_hooks> python '/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py' True setuptools.build_meta
.pkg: get_requires_for_build_sdist> python '/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py' True setuptools.build_meta
.pkg: build_sdist> python '/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py' True setuptools.build_meta
docs: install_package> python -I -m pip install --force-reinstall --no-deps '/Users/mitch/Documents/Code Projects/satp-kit/.tox/.tmp/package/10/satp_kit-0.1.dev3.tar.gz'
docs: internal error
Traceback (most recent call last):
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/session/cmd/run/single.py", line 48, in _evaluate
    code, outcomes = run_commands(tox_env, no_test)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/session/cmd/run/single.py", line 85, in run_commands
    status_main = run_command_set(tox_env, "commands", chdir, ignore_errors, outcomes)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/session/cmd/run/single.py", line 104, in run_command_set
    command_set: list[Command] = tox_env.conf[key]
                                 ~~~~~~~~~~~~^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/sets.py", line 122, in __getitem__
    return self.load(item)
           ^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/sets.py", line 133, in load
    return config_definition.__call__(self._conf, self.loaders, ConfigLoadArgs(chain, self.name, self.env_name))  # noqa: PLC2801
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/of_type.py", line 106, in __call__
    value = loader.load(key, self.of_type, self.factory, conf, args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/api.py", line 148, in load
    converted = self.build(key, of_type, factory, conf, raw, args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/toml/__init__.py", line 69, in build
    result = self.to(exploded, of_type, factory)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/convert.py", line 33, in to
    return self._to_typing(raw, of_type, factory)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/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/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/toml/__init__.py", line 88, in to_list
    return iter(validate(value, of))  # type: ignore[call-overload,no-any-return]
                ^^^^^^^^^^^^^^^^^^^
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/toml/_validate.py", line 37, in validate
    validate(va, entry_type)
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/toml/_validate.py", line 42, in validate
    validate(val, List[str])
  File "/Users/mitch/Documents/Code Projects/satp-kit/.venv/lib/python3.12/site-packages/tox/config/loader/toml/_validate.py", line 78, in validate
    raise TypeError(msg)
TypeError: 'mkdocs' is not list
  docs: FAIL code 2 (3.37 seconds)
  evaluation failed :( (3.41 seconds)

Version In Use

v1.0.0

Additional Context

- Cookiecutter version: 2.6.0
- Operating system: MacOS
- Python version: 3.12.5

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions