Repository navigation
Commit b35c8ee
🐛 fix(schema): cover every replace form in the TOML schema (#3941)
Closes #3939.
The conditional `replace = "if"` form added in #3771 was never wired
into the JSON schema or its generator, so editors that consume
`tox.schema.json` (such as tombi) reject `commands = [{ replace = "if",
... }]` with `Expected a value of type Array, but found Table`. The same
gap applied to `replace = "posargs"` and `replace = "glob"`, neither of
which had a schema representation either. Only `env` and `ref` were
partly modelled.
The fix replaces the loose two-branch `subs` definition with one
explicit object per replace form (`replace_env`, `replace_ref`,
`replace_posargs`, `replace_glob`, `replace_if`), discriminated by a
`const` on `replace`. A `replace_object` union groups all of them and is
referenced wherever a list item can extend its parent. The most
important case is the items of every `list[Command]` field, which is
what makes the extend-into-list pattern from the reproducer lint
cleanly. 🔧 Encoding `then`/`else` as the literal `true` schema (rather
than `{}`) keeps tombi happy while remaining valid draft-07.
To stop the same class of gap from shipping again, a guard test scrapes
`replace_type == \"...\"` tokens from `_replace.py` and fails if any are
missing a schema definition or a tombi-lint fixture. The existing
tombi-lint suite now hard-fails when `tombi` is absent instead of
silently skipping, and `tombi` is declared in the `test` dependency
group. A future PR that introduces a sixth replace form cannot reach
`main` without updating both the generator and the committed schema.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 6eb5c4f commit b35c8ee
5 files changed
Lines changed: 517 additions & 136 deletions
File tree
- docs/changelog
- src/tox
- session/cmd
- tests/session/cmd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
132 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
133 | 198 | | |
134 | 199 | | |
135 | 200 | | |
| |||
245 | 310 | | |
246 | 311 | | |
247 | 312 | | |
248 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
249 | 322 | | |
250 | 323 | | |
251 | 324 | | |
| |||
0 commit comments