Skip to content

Fix env name with dot losing description in TOML config#3722

Merged
gaborbernat merged 3 commits intotox-dev:mainfrom
worksbyfriday:fix-dotted-env-name-toml
Feb 17, 2026
Merged

Fix env name with dot losing description in TOML config#3722
gaborbernat merged 3 commits intotox-dev:mainfrom
worksbyfriday:fix-dotted-env-name-toml

Conversation

@worksbyfriday
Copy link
Contributor

Description

Fixes #3590

Environment names containing dots (e.g. "py3.11") in pyproject.toml had their descriptions silently ignored. tox list showed [no description] instead of the configured description.

Reproducer

[tool.tox.env."py3.11"]
description = "tox test"
$ tox list
py3.11 -> [no description]

Root cause

Three interrelated issues in toml_pyproject.py:

  1. sections() split the env name on dots: from_key("py3.11") treats . as the section separator, creating Section(prefix="py3", name="11") instead of preserving "py3.11" as the name.

  2. keys property split ALL dots: The full key "tool.tox.env.py3.11" was split into ["env", "py3", "11"]. get_loader() then tried to traverse dict["py3"]["11"] instead of dict["py3.11"], returning None (config not found).

  3. envs() yielded full key: When sections() is fixed to use test_env(), the full key becomes "tool.tox.env.py3.11" instead of just "py3.11", causing a phantom duplicate environment.

Fix

  • keys property: Build from prefix and name components directly instead of splitting the joined key on SEP. This preserves dots within the env name while still splitting structural path separators.
  • sections(): Use test_env(env_name) which correctly sets prefix="tool.tox.env" and name="py3.11" as an atomic unit.
  • envs(): Yield section.name instead of section.key to return just the env name.
  • get_base_sections(): Use test_env() for consistency.

After fix

$ tox list
py3.11 -> tox test

Environment names containing dots (e.g. "py3.11") in pyproject.toml
had their descriptions silently ignored. `tox list` showed
`[no description]` instead of the configured description.

Root cause: Three interrelated issues in toml_pyproject.py:

1. `sections()` called `from_key(env_name)` which splits on the
   first dot (the TOML SEP), turning "py3.11" into
   Section(prefix="py3", name="11") — wrong decomposition.

2. The `keys` property split the full key on ALL dots, so
   "tool.tox.env.py3.11" became ["env", "py3", "11"] instead of
   ["env", "py3.11"]. `get_loader()` then tried to traverse
   dict["py3"]["11"] instead of dict["py3.11"], silently failing.

3. `envs()` yielded `section.key` (the full dotted path) instead of
   `section.name` (the env name), causing duplicate entries when
   `sections()` was fixed to use `test_env()`.

Fix:
- `keys`: build from prefix/name components directly instead of
  splitting the joined key, preserving dots within the name.
- `sections()`: use `test_env(env_name)` which correctly sets
  prefix="tool.tox.env" and name="py3.11" as a single unit.
- `envs()`: yield `section.name` instead of `section.key`.
- `get_base_sections()`: use `test_env()` for consistency.

Closes tox-dev#3590
pre-commit-ci bot and others added 2 commits February 17, 2026 11:42
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

LGTM

@gaborbernat gaborbernat merged commit 83b3ed8 into tox-dev:main Feb 17, 2026
3 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.

Env name with dot in TOML config

2 participants