Skip to content

STY: setup python formatting with ruff - #392

Merged
glesur merged 4 commits into
idefix-code:developfrom
neutrinoceros:sty/python-formatting
Jul 16, 2026
Merged

STY: setup python formatting with ruff#392
glesur merged 4 commits into
idefix-code:developfrom
neutrinoceros:sty/python-formatting

Conversation

@neutrinoceros

Copy link
Copy Markdown
Collaborator

No description provided.

@neutrinoceros

neutrinoceros commented Jul 15, 2026

Copy link
Copy Markdown
CollaboratorAuthor

I eyeballed every change and made a couple manual tweaks around trailing commas, which I recommend reading about as it's about the only place where ruff format leaves a choice to users.

ref https://docs.astral.sh/ruff/formatter/#line-breaks

@neutrinoceros

Copy link
Copy Markdown
CollaboratorAuthor

Of course this PR should be low priority as it brings very little value, however I'd still like to ask for a rapid cycle because of its size: the longer it lingers in the backlog, the more pain it'll be to maintain it.

@neutrinoceros
neutrinoceros marked this pull request as ready for review July 15, 2026 08:23
@glesur
glesur requested a review from CopilotJuly 15, 2026 11:09

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces Ruff-based Python formatting and applies the formatter across the repository to standardize style and reduce formatting drift in scripts, tests, and tooling.

Changes:

  • Add ruff-format to pre-commit and pin Ruff target version to Python 3.10.
  • Apply Ruff formatting across many Python test drivers and helper scripts.
  • Record the formatting-only commit in .git-blame-ignore-revs to keep blame history useful.

Reviewed changes

Copilot reviewed 98 out of 99 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
test/utils/lookupTable/testme.pyRuff formatting (spacing/quotes/indentation).
test/utils/dumpImage/testme.pyRuff formatting (spacing/blank line after docstring).
test/utils/columnDensity/testme.pyRuff formatting (spacing/blank line after docstring).
test/SelfGravity/UniformCollapse/testme.pyRuff formatting (indentation/spacing, minor layout).
test/SelfGravity/UniformCollapse/python/testidefix.pyRuff formatting (spacing/quotes/line wraps).
test/SelfGravity/RandomSphereCartesian/testme.pyRuff formatting (indentation/spacing).
test/SelfGravity/RandomSphereCartesian/python/testidefix.pyRuff formatting (function signature spacing, wraps).
test/SelfGravity/RandomSphere/testme.pyRuff formatting (indentation/spacing).
test/SelfGravity/RandomSphere/python/testidefix.pyRuff formatting (quotes/spacing/wraps).
test/SelfGravity/JeansInstability/testme.pyRuff formatting (indentation/spacing).
test/SelfGravity/JeansInstability/python/testidefix.pyRuff formatting (spacing/quotes).
test/SelfGravity/DustyCollapse/testme.pyRuff formatting (indentation/spacing).
test/SelfGravity/DustyCollapse/python/testidefix.pyRuff formatting (spacing, expression layout).
test/Pluto/HD/sod/python/testidefix.pyRuff formatting (argparse formatting, wraps).
test/Planet/PlanetTorque3D/testme.pyRuff formatting (indentation/spacing).
test/Planet/PlanetTorque3D/python/testidefix.pyRuff formatting (spacing/plot section layout).
test/Planet/PlanetSpiral2D/testme.pyRuff formatting (indentation/spacing).
test/Planet/PlanetSpiral2D/python/testidefix.pyRuff formatting (operators/line wraps).
test/Planet/PlanetsIsActiveRK52D/testme.pyRuff formatting (indentation/spacing).
test/Planet/PlanetsIsActiveRK52D/python/testidefix.pyRuff formatting (line wraps, condition formatting).
test/Planet/PlanetPlanetRK42D/testme.pyRuff formatting (indentation/spacing, asserts layout).
test/Planet/PlanetPlanetRK42D/python/testidefix.pyRuff formatting (spacing/line wraps).
test/Planet/PlanetMigration2D/testme.pyRuff formatting (indentation/spacing).
test/Planet/PlanetMigration2D/python/testidefix.pyRuff formatting (spacing/plot layout).
test/Planet/Planet3Body/testme.pyRuff formatting (indentation/spacing).
test/Planet/Planet3Body/python/testidefix.pyRuff formatting (spacing/plot section layout).
test/MHD/sphBragViscosity/testme.pyRuff formatting (indentation/spacing/comments alignment).
test/MHD/sphBragViscosity/python/testidefix.pyRuff formatting (spacing/quotes/loops).
test/MHD/sphBragTDiffusion/testme.pyRuff formatting (indentation/spacing).
test/MHD/sphBragTDiffusion/python/testidefix.pyRuff formatting (spacing/quotes/loops).
test/MHD/sod/testme.pyRuff formatting (indentation/spacing, loop layout).
test/MHD/sod-iso/testme.pyRuff formatting (indentation/spacing, loop layout).
test/MHD/ShearingBox/testme.pyRuff formatting (indentation/spacing, tolerance assignment).
test/MHD/ShearingBox/python/testidefix.pyRuff formatting; retains a + +(...) expression in error norm.
test/MHD/ResistiveAlfvenWave/testme.pyRuff formatting (indentation/spacing).
test/MHD/ResistiveAlfvenWave/python/testidefix.pyRuff formatting (spacing/quotes).
test/MHD/OrszagTang3D/testme.pyRuff formatting (indentation/spacing).
test/MHD/OrszagTang/testme.pyRuff formatting (list layout/indentation).
test/MHD/MTI/testme.pyRuff formatting (indentation/spacing).
test/MHD/MTI/python/testidefix.pyRuff formatting (spacing/quotes/line wraps).
test/MHD/LinearWaveTest/testme.pyRuff formatting (function layout/indentation).
test/MHD/LinearWaveTest/python/testidefix.pyRuff formatting (argparse/loop indentation).
test/MHD/HallWhistler/testme.pyRuff formatting (indentation/spacing).
test/MHD/HallWhistler/python/testidefix.pyRuff formatting (spacing/quotes/plot section layout).
test/MHD/FargoMHDSpherical/testme.pyRuff formatting (indentation/spacing).
test/MHD/Coarsening/testme.pyRuff formatting (indentation/spacing).
test/MHD/Coarsening/python/testidefix.pyRuff formatting (spacing/quotes/line wraps).
test/MHD/clessTDiffusion/testme.pyRuff formatting (indentation/spacing).
test/MHD/clessTDiffusion/python/testidefix.pyRuff formatting (spacing/quotes).
test/MHD/AxisFluxTube/testme.pyRuff formatting (indentation/spacing).
test/MHD/AxisFluxTube/python/checkAxisBounds.pyRuff formatting (spacing/quotes).
test/MHD/AmbipolarShearingBox/python/testidefix.pyRuff formatting (spacing/quotes).
test/MHD/AmbipolarCshock3D/testme.pyRuff formatting (indentation/spacing).
test/MHD/AmbipolarCshock3D/python/testidefix.pyRuff formatting (spacing/quotes/line wraps).
test/MHD/AmbipolarCshock/testme.pyRuff formatting (indentation/spacing).
test/MHD/AmbipolarCshock/python/testidefix.pyRuff formatting (spacing/quotes/line wraps).
test/IO/xdmf/testme.pyRuff formatting (indentation/spacing, small refactor layout).
test/IO/pydefix/testme.pyRuff formatting (indentation/spacing).
test/IO/pydefix/pydefix_example.pyRuff formatting (indentation/line wraps).
test/IO/dump/testme.pyRuff formatting (indentation/spacing).
test/HD/ViscousFlowPastCylinder/testme.pyRuff formatting (indentation/spacing).
test/HD/ViscousDisk/testme.pyRuff formatting (indentation/spacing).
test/HD/ViscousDisk/python/testidefix.pyRuff formatting (spacing/quotes/line wraps).
test/HD/thermalDiffusion/testme.pyRuff formatting (indentation/spacing).
test/HD/thermalDiffusion/python/testidefix.pyRuff formatting (spacing/quotes).
test/HD/sod/testme.pyRuff formatting (indentation/spacing, loop layout).
test/HD/sod/python/testidefix.pyRuff formatting (argparse formatting, wraps).
test/HD/sod/pydefix_example.pyRuff formatting (spacing/quotes).
test/HD/sod-iso/testme.pyRuff formatting (indentation/spacing, loop layout).
test/HD/sod-iso/python/testidefix.pyRuff formatting (spacing/quotes/wraps).
test/HD/ShearingBox/testme.pyRuff formatting (indentation/spacing).
test/HD/ShearingBox/python/testidefix.pyRuff formatting; retains a + +(...) expression in error norm.
test/HD/SedovBlastWave/testme.pyRuff formatting (indentation/spacing, comment spacing).
test/HD/SedovBlastWave/python/testidefix.pyRuff formatting (spacing/quotes/wraps).
test/HD/MachReflection/testme.pyRuff formatting (indentation/spacing).
test/HD/FargoPlanet/testme.pyRuff formatting (function layout/indentation).
test/Dust/DustyWave/testme.pyRuff formatting (indentation/spacing).
test/Dust/DustyWave/python/testidefix.pyRuff formatting (spacing/quotes/wraps).
test/Dust/DustyShock/testme.pyRuff formatting (indentation/spacing).
test/Dust/DustyShock/python/testidefix.pyRuff formatting (spacing/quotes/wraps).
test/Dust/DustEnergy/testme.pyRuff formatting (indentation/spacing).
test/Dust/DustEnergy/python/testidefix.pyRuff formatting (spacing/quotes).
test.pyRuff formatting (indentation/blank lines).
pytools/vtk_io.pyRuff formatting (line wraps, minor whitespace).
pytools/tests/test_idfx_test_run.pyRuff formatting (rewrap long expected structure).
pytools/sod.pyRuff formatting (float literals/spacing, rewrap function defs).
pytools/idfx_io.pyRuff formatting (remove stray blank line, quote normalization).
pytools/dump_io.pyRuff formatting (blank line after module docstring).
make_tarballs.pyRuff formatting (minor spacing in expression).
doc/source/plot_idefix_bench.pyRuff formatting (quote normalization, spacing).
doc/source/conf.pyRuff formatting (quote normalization, list/dict formatting).
.pre-commit-config.yamlAdd ruff-format hook and set --target-version=py310 for Ruff hooks.
.git-blame-ignore-revsAdd the Ruff-formatting commit to blame ignore list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

error = np.sqrt(
(V["vx"] / v0 - y.sol(V["t"])[0, :]) ** 2
+ (V["vy"] / v0 - y.sol(V["t"])[1, :]) ** 2
+ +((V["vz"] / v0 - y.sol(V["t"])[2, :]) ** 2)
error = np.sqrt(
(V["vx"] / v0 - y.sol(V["t"])[0, :]) ** 2
+ (V["vy"] / v0 - y.sol(V["t"])[1, :]) ** 2
+ +((V["vz"] / v0 - y.sol(V["t"])[2, :]) ** 2)
@glesur
glesur merged commit 392d89d into idefix-code:developJul 16, 2026
41 checks passed
@neutrinoceros
neutrinoceros deleted the sty/python-formatting branch July 16, 2026 20:37
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@neutrinoceros@glesur