🐛 fix(tox-toml-fmt): keep env tables as separate sections#231
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Feb 18, 2026
Merged
🐛 fix(tox-toml-fmt): keep env tables as separate sections#231gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat merged 1 commit intotox-dev:mainfrom
Conversation
tox has a bug where dotted keys under [env] (e.g. "3.13t".base_python) cause a RecursionError in the config loader. The formatter was collapsing [env.NAME] sections into dotted keys under [env] in short mode, triggering this crash. Environment tables are now always kept as separate [env.NAME] sections regardless of the table_format setting. Dotted keys under [env] are expanded into their own sections, and empty parent tables left behind after expansion are cleaned up. Sub-tables within an environment (e.g. [env.test.sub]) still follow the table_format setting as before.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #231 +/- ##
==========================================
+ Coverage 95.61% 98.58% +2.96%
==========================================
Files 19 1 -18
Lines 2968 212 -2756
Branches 2968 212 -2756
==========================================
- Hits 2838 209 -2629
+ Misses 63 0 -63
+ Partials 67 3 -64
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
table_format = "short", the formatter was collapsing[env.NAME]sections into dotted keys under[env](e.g.fix.description = "fix"). This triggers a RecursionError in tox's TOML config loader, which cannot handle dotted keys under the[env]table. 🐛The fix ensures
[env.*]tables are always kept as separate sections regardless of thetable_formatsetting. When dotted keys already exist under[env], they are expanded into their own[env.NAME]sections, and any empty parent table left behind is cleaned up. Sub-tables within an environment (e.g.[env.test.sub]) still follow thetable_formatsetting, so only the first level of environment names is protected.This is a targeted fix —
env_run_base,env_pkg_base, and all other tables continue to respect thetable_formatoption as before.