Commit 83b3ed8
Fix env name with dot losing description in TOML config (#3722)
## 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
```toml
[tool.tox.env."py3.11"]
description = "tox test"
```
```console
$ 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
```console
$ tox list
py3.11 -> tox test
```
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0ee48ce commit 83b3ed8
2 files changed
Lines changed: 24 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
63 | 78 | | |
64 | 79 | | |
65 | 80 | | |
| |||
113 | 128 | | |
114 | 129 | | |
115 | 130 | | |
116 | | - | |
| 131 | + | |
117 | 132 | | |
118 | 133 | | |
119 | 134 | | |
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
123 | | - | |
| 138 | + | |
124 | 139 | | |
125 | 140 | | |
126 | | - | |
| 141 | + | |
127 | 142 | | |
128 | 143 | | |
129 | 144 | | |
| |||
0 commit comments