From 37b14d98667f6e9a13a733aae7dabc8456e2a97b Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sat, 9 Mar 2024 15:47:58 +0000 Subject: [PATCH] Preserve formatting with tomlkit --- .github/workflows/update_backend.yml | 2 +- .github/workflows/update_backend_version.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update_backend.yml b/.github/workflows/update_backend.yml index f3bf6475..07a068b2 100644 --- a/.github/workflows/update_backend.yml +++ b/.github/workflows/update_backend.yml @@ -20,7 +20,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install toml json + pip install tomlkit pip install . python -c 'import pysr' diff --git a/.github/workflows/update_backend_version.py b/.github/workflows/update_backend_version.py index 868ddc77..2ff1bb87 100644 --- a/.github/workflows/update_backend_version.py +++ b/.github/workflows/update_backend_version.py @@ -2,7 +2,7 @@ import sys from pathlib import Path -import toml +import tomlkit new_backend_version = sys.argv[1] @@ -10,7 +10,7 @@ juliapkg_json = Path(__file__).parent / ".." / ".." / "pysr" / "juliapkg.json" with open(pyproject_toml) as toml_file: - pyproject_data = toml.load(toml_file) + pyproject_data = tomlkit.parse(toml_file.read()) with open(juliapkg_json) as f: juliapkg_data = json.load(f) @@ -21,7 +21,7 @@ juliapkg_data["packages"]["SymbolicRegression"]["version"] = f"={new_backend_version}" with open(pyproject_toml, "w") as toml_file: - toml.dump(pyproject_data, toml_file) + toml_file.write(tomlkit.dumps(pyproject_data)) with open(juliapkg_json, "w") as f: json.dump(juliapkg_data, f, indent=4)