Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat Python code with Ruff #1081

Merged
merged 2 commits into from
Mar 13, 2024

Conversation

akx
Copy link
Contributor

@akx akx commented Feb 24, 2024

This PR:

  • upgrades Ruff and fixes pyproject.toml's keys so Ruff doesn't warn about them
  • configures the line-length to 119; the default for Ruff (from Black) is 88, which is pretty narrow for modern terminals.
    • Across all projects I happen to have checked out locally, the median configured line-length is 119:
      $ ag line-length */*.{cfg,toml} | cut -f2 -d= | grep -oE '\d+' | datamash -H count 1 median 1 mean 1
      count(88)	median(88)	mean(88)
      193	119	118.35751295337
      
  • runs Ruff formatting as a separate commit that's attributed to Ruff only.
    • The second commit should not need to be reviewed very meticulously, since it is purely mechanical.
    • However, the method to get there might be of interest:
      1. ruff --select=COM818,COM819 --fix . to remove trailing commas from expressions that would otherwise trigger the formatter's magic comma newlining
      2. ruff format . to format everything
      3. ruff --select=COM --fix . to add trailing commas to multi-line parameter lists, etc.
      4. ruff format . once more to ensure the added trailing commas are up to spec

Important

This PR should be merged with a regular merge, not a squash, so the reformatting commit can be added to .git-blame-ignore-revs.

Copy link

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@akx akx force-pushed the ruff-format branch 3 times, most recently from 0f51b78 to da953a2 Compare March 13, 2024 14:08
@akx akx marked this pull request as ready for review March 13, 2024 14:15
@Titus-von-Koeller Titus-von-Koeller merged commit 06029dd into bitsandbytes-foundation:main Mar 13, 2024
23 checks passed
@akx akx deleted the ruff-format branch March 13, 2024 14:35
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.

None yet

2 participants