Skip to content

Replace black/isort/pydocstyle with ruff in pre-commit configuration#457

Draft
mahidhiman12 wants to merge 10 commits intoarviz-devs:mainfrom
mahidhiman12:ruff-migration
Draft

Replace black/isort/pydocstyle with ruff in pre-commit configuration#457
mahidhiman12 wants to merge 10 commits intoarviz-devs:mainfrom
mahidhiman12:ruff-migration

Conversation

@mahidhiman12
Copy link
Copy Markdown
Contributor

Closes #451

Changes

  • Replaced black, isort, and pydocstyle pre-commit hooks with ruff and ruff-format in .pre-commit-config.yaml
  • Updated pyproject.toml to remove [tool.black], [tool.isort], [tool.pydocstyle] sections and add [tool.ruff] config aligned with arviz-base
  • Kept pylint as ruff does not replace its checks
  • Applied ruff auto-formatting fixes across the codebase to keep CI green

Status

  • Config changes (.pre-commit-config.yaml, pyproject.toml)
  • Ruff auto-fixes applied
  • Remaining manual fixes (PLW1508, D400) -> in progress

Marking as draft while final fixes are completed.

@mahidhiman12
Copy link
Copy Markdown
Contributor Author

@OriolAbril I've opened this as a draft PR with the config changes and ruff auto-fixes applied following the workflow you suggested. Before I proceed to fix the remaining manual errors (PLW1508 and D400), could you let me know if the [tool.ruff] settings in pyproject.toml look correct, or if anything needs tweaking? I want to make sure the config is finalized before committing more fixes on top of it.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Mar 6, 2026

Documentation build overview

📚 arviz-plots | 🛠️ Build #31821381 | 📁 Comparing 28f40df against latest (3fef0a6)


🔍 Preview build

Show files changed (97 files in total): 📝 97 modified | ➕ 0 added | ➖ 0 deleted
File Status
contributing/new_plot.html 📝 modified
gallery/add_reference_bands.html 📝 modified
gallery/add_reference_lines.html 📝 modified
gallery/combine_plots.html 📝 modified
gallery/index.html 📝 modified
gallery/plot_autocorr.html 📝 modified
gallery/plot_bf.html 📝 modified
gallery/plot_compare.html 📝 modified
gallery/plot_convergence_dist.html 📝 modified
gallery/plot_dgof.html 📝 modified
gallery/plot_dgof_dist.html 📝 modified
gallery/plot_dist_ecdf.html 📝 modified
gallery/plot_dist_hist.html 📝 modified
gallery/plot_dist_kde.html 📝 modified
gallery/plot_dist_models.html 📝 modified
gallery/plot_dist_qds.html 📝 modified
gallery/plot_ecdf_coverage.html 📝 modified
gallery/plot_ecdf_pit.html 📝 modified
gallery/plot_energy.html 📝 modified
gallery/plot_ess_evolution.html 📝 modified
gallery/plot_ess_local.html 📝 modified
gallery/plot_ess_models.html 📝 modified
gallery/plot_ess_quantile.html 📝 modified
gallery/plot_forest.html 📝 modified
gallery/plot_forest_ess.html 📝 modified
gallery/plot_forest_models.html 📝 modified
gallery/plot_forest_pp_obs.html 📝 modified
gallery/plot_forest_shade.html 📝 modified
gallery/plot_khat.html 📝 modified
gallery/plot_khat_aesthetics.html 📝 modified
gallery/plot_khat_facet_cols.html 📝 modified
gallery/plot_khat_facet_grid.html 📝 modified
gallery/plot_lm.html 📝 modified
gallery/plot_loo_pit.html 📝 modified
gallery/plot_mcse.html 📝 modified
gallery/plot_pair.html 📝 modified
gallery/plot_pair_distribution.html 📝 modified
gallery/plot_pair_focus.html 📝 modified
gallery/plot_pair_focus_distribution.html 📝 modified
gallery/plot_parallel.html 📝 modified
gallery/plot_pava_calibration.html 📝 modified
gallery/plot_ppc_censored.html 📝 modified
gallery/plot_ppc_coverage.html 📝 modified
gallery/plot_ppc_dist.html 📝 modified
gallery/plot_ppc_interval.html 📝 modified
gallery/plot_ppc_pava_residuals.html 📝 modified
gallery/plot_ppc_pit.html 📝 modified
gallery/plot_ppc_rootogram.html 📝 modified
gallery/plot_ppc_tstat.html 📝 modified
gallery/plot_prior_posterior.html 📝 modified
gallery/plot_psense.html 📝 modified
gallery/plot_psense_quantities.html 📝 modified
gallery/plot_rank.html 📝 modified
gallery/plot_rank_dist.html 📝 modified
gallery/plot_ridge.html 📝 modified
gallery/plot_ridge_multiple.html 📝 modified
gallery/plot_trace.html 📝 modified
gallery/plot_trace_dist.html 📝 modified
_modules/arviz_plots/plot_collection.html 📝 modified
_modules/arviz_plots/plot_matrix.html 📝 modified
_modules/arviz_plots/style.html 📝 modified
_modules/arviz_plots/visuals.html 📝 modified
api/generated/arviz_plots.PlotCollection.generate_aes_dt.html 📝 modified
api/generated/arviz_plots.plot_bf.html 📝 modified
api/generated/arviz_plots.plot_dist.html 📝 modified
api/generated/arviz_plots.plot_ecdf_pit.html 📝 modified
_modules/arviz_plots/plots/combine.html 📝 modified
_modules/arviz_plots/plots/compare_plot.html 📝 modified
_modules/arviz_plots/plots/convergence_dist_plot.html 📝 modified
_modules/arviz_plots/plots/dgof_dist_plot.html 📝 modified
_modules/arviz_plots/plots/dgof_plot.html 📝 modified
_modules/arviz_plots/plots/ecdf_plot.html 📝 modified
_modules/arviz_plots/plots/energy_plot.html 📝 modified
_modules/arviz_plots/plots/ess_plot.html 📝 modified
_modules/arviz_plots/plots/evolution_plot.html 📝 modified
_modules/arviz_plots/plots/forest_plot.html 📝 modified
_modules/arviz_plots/plots/loo_pit_plot.html 📝 modified
_modules/arviz_plots/plots/mcse_plot.html 📝 modified
_modules/arviz_plots/plots/pair_focus_plot.html 📝 modified
_modules/arviz_plots/plots/pair_plot.html 📝 modified
_modules/arviz_plots/plots/parallel_plot.html 📝 modified
_modules/arviz_plots/plots/pava_calibration_plot.html 📝 modified
_modules/arviz_plots/plots/pava_residual_plot.html 📝 modified
_modules/arviz_plots/plots/ppc_censored_plot.html 📝 modified
_modules/arviz_plots/plots/ppc_interval_plot.html 📝 modified
_modules/arviz_plots/plots/ppc_pit_plot.html 📝 modified
_modules/arviz_plots/plots/ppc_rootogram_plot.html 📝 modified
_modules/arviz_plots/plots/ppc_tstat.html 📝 modified
_modules/arviz_plots/plots/psense_dist_plot.html 📝 modified
_modules/arviz_plots/plots/psense_quantities_plot.html 📝 modified
_modules/arviz_plots/plots/rank_dist_plot.html 📝 modified
_modules/arviz_plots/plots/rank_plot.html 📝 modified
_modules/arviz_plots/plots/ridge_plot.html 📝 modified
_modules/arviz_plots/plots/trace_dist_plot.html 📝 modified
_modules/arviz_plots/plots/trace_plot.html 📝 modified
_modules/arviz_plots/plots/utils.html 📝 modified
_modules/arviz_plots/backend/none/core.html 📝 modified

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.16%. Comparing base (3fef0a6) to head (28f40df).

Files with missing lines Patch % Lines
src/arviz_plots/backend/plotly/core.py 0.00% 2 Missing ⚠️
src/arviz_plots/plot_collection.py 83.33% 1 Missing ⚠️
src/arviz_plots/plots/ppc_tstat.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #457      +/-   ##
==========================================
- Coverage   85.17%   85.16%   -0.02%     
==========================================
  Files          60       60              
  Lines        7069     7062       -7     
==========================================
- Hits         6021     6014       -7     
  Misses       1048     1048              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

Going over the logs to see the reasons why the checks failed:

  • end of files and trailing whitespaces are fine, there will be changes to many files but it is no problem
  • new per file ruff ignores
    • Any "D" related message should be ignored for anything inside docs/source/gallery, the E501 one (line too long) should be ignored too. After removing those please check what errors you still get from files inside that folder so we can see if they are relevant or should be ignored too.
  • either more per-file ignores or within file noqa comments
    • Things like Link to this page with the [bokeh tab selected]({site_url}/gallery/{basename}.html?backend=bokeh#synchronised-tabs) in the gallery generator are ok and should be kept as is not trigger errors or be reformatted
  • ...

There are too many errors for now. You should run tox -e check twice with the updated settings (so the formatter and auto fixer takes care of some of the errors) then commit so we can focus on the non-automatically fixable issues. If you do this commit idependently from the config settings if we see the formatter ended up being too agressive you can undo only the commit with the automatic changes while keeping everything else.

Comment thread .pre-commit-config.yaml Outdated
@mahidhiman12
Copy link
Copy Markdown
Contributor Author

Updated the hook name to ruff-check, bumped to latest version (v0.15.6), and added per-file ignores for docs/source/gallery and docs/sphinxext.
Ran tox -e check multiple times, committing config changes and auto-fixes separately as suggested. 387 errors remain that need manual fixes.
let me know which to address.

@OriolAbril
Copy link
Copy Markdown
Member

I would put this on hold for it to be fixed during GSoC. Nearly 400 errors to fix manually across so many files is a lot of work and will generate many merge conflicts across the board.

Sign up for free to 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.

MAINT: Migrate from black/isort/pylint to ruff for linting and formatting

3 participants