pydata / pydata/xarray

Use `ruff` for formatting

Open
#8,760 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-internals
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

Use ruff for formatting

Context

Ruff was introduced in https://github.com/pydata/xarray/issues/7458. Arguments in favor were that it is faster, and combines multiple tools in a single tool (eg flake8, pyflakes, isort, pyupgrade ).

This switches our primary linter to Ruff. As adervertised, Ruff is very fast. Plust we get the benefit of using a single tool that combines the previous functionality of pyflakes, isort, and pyupgrade.

Suggestion

Suggestion: To move on with ruff replacement of tools, introduce ruff-format to replace black (See ruff Usage for integration with pre-commit). See issue

Pandas uses ruff and ruff-format:
https://github.com/pandas-dev/pandas/blob/63dc0f76faa208450b8aaa57246029fcf94d015b/.pre-commit-config.yaml#L24

Ruff is capable of dosctring formatting:
https://docs.astral.sh/ruff/formatter/#docstring-formatting

Ruff can format Jupyter Notebooks:
https://docs.astral.sh/ruff/faq/#does-ruff-support-jupyter-notebooks

So, introducing the ruff formatter might remove the need for black and blackdoc

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the repository's pre-commit configuration and the existing Black and blackdoc setup. Compare it with Ruff's formatter and notebook support described in the linked Ruff documentation. Done means Ruff formatting replaces the current formatter tooling without leaving the previous formatter requirements in the workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.