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

Replace isort and flake8 with Ruff checker #20442

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Nov 3, 2024

This PR replaces isort and flake8 lint tools with Ruff check tools. The rational is that Ruff is very fast, which has earned it's recent popularity. It also has Drop-in parity with flake8, isort, and Black.

With the transition, the old configurations are mapped to new configurations. Some of these were redundant or some ignores have no effect, so are not transitioned.

This PR does not replace Black with Ruff format, as this would incur more changed files (I'm seeking for minimal changes to source files). But a follow-up PR can replace Black with Ruff format, with the updated source files.

@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.01%. Comparing base (f9ea1a0) to head (e22bffa).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/models/model.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20442   +/-   ##
=======================================
  Coverage   82.01%   82.01%           
=======================================
  Files         514      514           
  Lines       47183    47192    +9     
  Branches     7409     7408    -1     
=======================================
+ Hits        38697    38706    +9     
  Misses       6696     6696           
  Partials     1790     1790           
Flag Coverage Δ
keras 81.87% <75.00%> (+<0.01%) ⬆️
keras-jax 64.92% <75.00%> (+<0.01%) ⬆️
keras-numpy 59.87% <75.00%> (+<0.01%) ⬆️
keras-tensorflow 65.92% <75.00%> (+<0.01%) ⬆️
keras-torch 64.87% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! We can definitely consider this change. Please take a look at the code format check failure.

pyproject.toml Outdated Show resolved Hide resolved
@mwtoews
Copy link
Contributor Author

mwtoews commented Nov 3, 2024

The rational is that Ruff is very fast

Looking at the speedup via time bash shell/lint.sh (and commenting out black ...) the results in master are:

$ time bash shell/lint.sh
...
real	0m3.153s
user	0m29.378s
sys	0m0.430s

and with this PR are significantly faster:

$ time bash shell/lint.sh
...
real	0m0.030s
user	0m0.029s
sys	0m0.053s

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Nov 4, 2024
@fchollet fchollet merged commit 192b7b2 into keras-team:master Nov 4, 2024
6 checks passed
@google-ml-butler google-ml-butler bot removed ready to pull Ready to be merged into the codebase kokoro:force-run labels Nov 4, 2024
@mwtoews mwtoews deleted the ruff-check branch November 4, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants