Skip to content

MNT: replace black and isort with ruff format and lint #1496

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

Merged
merged 3 commits into from
May 25, 2025

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented May 22, 2025

This maintenance PR does the following:

  • Replace Black with the Ruff formatter
  • Replace isort with Ruff's "I" lint check
  • Update the Ruff version in pre-commit, which changes a few source files
  • Remove target-version from ruff configuration, since this is automatically evaluated
  • Add ruff to requirements-dev.txt
  • Update relevant excerpts of CONTRIBUTING.md with these changes

Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.56%. Comparing base (6a38287) to head (9bd3aff).
Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1496      +/-   ##
==========================================
+ Coverage   96.50%   96.56%   +0.06%     
==========================================
  Files          20       20              
  Lines        1830     1833       +3     
==========================================
+ Hits         1766     1770       +4     
+ Misses         64       63       -1     

☔ 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.

@@ -8,15 +8,6 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
Copy link
Member

Choose a reason for hiding this comment

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

I am okay removing isort. However, I am not sure about black. Do the formatters conflict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Ruff formatter is a drop-in replacement for Black, but much faster (100x). According to these docs "> 99.9% of lines are formatted identically", so this may explain some minor differences of formatting found in this PR.

Copy link
Member

@snowman2 snowman2 May 24, 2025

Choose a reason for hiding this comment

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

Sounds worth a try. Can always swap it back later. Probably should remove the black badge in the readme.

@snowman2 snowman2 merged commit c9f4ddf into pyproj4:main May 25, 2025
17 checks passed
@snowman2
Copy link
Member

Thanks @mwtoews 👍

@mwtoews mwtoews deleted the mnt-replace-black-isort-with-ruff branch May 25, 2025 03:21
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.

2 participants