#!/usr/bin/env bash # Reproduces the CI "Preparse .sage files" step locally, so `ruff check` sees # the same generated *.sage.py files that the pipeline lints. Run this before # `sage --python -m ruff check --no-respect-gitignore .` to catch issues that # only show up in the generated output (e.g. missing trailing newlines). # # The generated files are gitignored; clean them up afterwards with: # git clean -x sage/ playground/ set -e for f in $(find . -name "*.sage" -not -path "./playground/*"); do sage --preparse "$f" printf 'from sage.all import * # noqa: F401,F403\n%s\n' "$(cat "${f}.py")" > "${f}.py" done