From ec3f1afb41aa091a6e027777a13a8bb99ad80c24 Mon Sep 17 00:00:00 2001 From: Adam Ladachowski Date: Sat, 14 Feb 2026 02:51:48 +0100 Subject: [PATCH] Fix TOML save order: write scalars before sections TOML sections capture all subsequent keys until the next section. default_remote was being written after [remotes] section, making it appear as part of remotes dict instead of top-level config. Co-Authored-By: Claude Opus 4.5 --- tensors/config.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tensors/config.py b/tensors/config.py index 89c287b..b7d4f9b 100644 --- a/tensors/config.py +++ b/tensors/config.py @@ -120,6 +120,18 @@ def save_config(config: dict[str, Any]) -> None: CONFIG_DIR.mkdir(parents=True, exist_ok=True) lines: list[str] = [] + # Write scalar values first (before any sections) + for key, value in config.items(): + if not isinstance(value, dict): + if isinstance(value, str): + lines.append(f'{key} = "{value}"') + else: + lines.append(f"{key} = {value}") + + if lines: + lines.append("") + + # Then write sections (dicts) for key, value in config.items(): if isinstance(value, dict): lines.append(f"[{key}]") @@ -129,10 +141,6 @@ def save_config(config: dict[str, Any]) -> None: else: lines.append(f"{k} = {v}") lines.append("") - elif isinstance(value, str): - lines.append(f'{key} = "{value}"') - else: - lines.append(f"{key} = {value}") CONFIG_FILE.write_text("\n".join(lines) + "\n")