Skip to content

Commit

Permalink
Preserve formatting with tomlkit
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Mar 9, 2024
1 parent d684988 commit 37b14d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update_backend.yml
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/update_backend_version.py
Expand Up @@ -2,15 +2,15 @@
import sys
from pathlib import Path

import toml
import tomlkit

new_backend_version = sys.argv[1]

pyproject_toml = Path(__file__).parent / ".." / ".." / "pyproject.toml"
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)
Expand All @@ -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)

0 comments on commit 37b14d9

Please sign in to comment.