Skip to content

Investigate replacing pyupgrade, black, isort and flake8 with ruff #17570

Open
@facutuesca

Description

@facutuesca

Since I couldn't find any discussion about ruff in existing issues, I'm opening this one to see if there's interest and to document what I've found so far.

Currently, Python linting and formatting (via make lint and make reformat) is done via black, isort, pyupgrade and flake8.

ruff can be used as an (almost) drop-in replacement for most of these. The only thing not supported is custom flake8 plugins, like the one defined here.

I have a branch where I tested the migration by:

  • Replacing pyupgrade with ruff's pyupgrade rules
  • Replacing isort with ruff''s isort rules
  • Replacing black with ruff format
  • Replacing flake8's default rules with ruff check
  • Replacing flake8-pytest-style default rules with ruff's flake8-pytest-style rules
  • Still running flake8, but only selecting the custom WH plugin mentioned above.

After migrating, running with a warm cache I get around a 10 second improvement in both make commands, and make reformat is now almost instant:

Before (black+pyupgrade+isort+flake8):

make reformat  0.08s user 0.04s system 1% cpu 10.757 total

make lint  0.15s user 0.07s system 0% cpu 33.592 total

---------------

After (ruff+flake8):

make reformat  0.07s user 0.04s system 14% cpu 0.754 total

make lint  0.14s user 0.07s system 0% cpu 23.736 total

cc @miketheman @woodruffw

Metadata

Metadata

Assignees

No one assigned

    Labels

    developer experienceAnything that improves the experience for Warehouse devstestingTest infrastructure and individual tests

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions