[SPARK-54632][PYTHON] Add the option to use ruff for lint #53378
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add
ruffas an option to lint our code.Why are the changes needed?
Our pinned
flake8version is just too old - it can't even run on 3.12+. We can upgrade flake8 version but I think gradually switch toruffis a better options. The main reason isruffis much much faster thanflake8.ruffreturns the result almost immediately (ms-level) on whole spark repo - which means we can even hook it in the pre-commit in the future.It is surprisingly compatible with flake8 - there's almost no code change needed (with two extra ignored lint types which we can fix in the future). Everything it finds is a real issue instead of a different taste.
ruffcan also serve as a black-compatible formatter which means we can probably ditch bothflake8andblackin the future.For now we only enable this option - it's not hooked into any CI or full
./dev/lint-python. However, I think we should do that soon.Does this PR introduce any user-facing change?
No
How was this patch tested?
Local lint test passed.
Was this patch authored or co-authored using generative AI tooling?
No