[SPARK-56018][PYTHON] Use ruff as formatter#54840
Closed
gaogaotiantian wants to merge 6 commits intoapache:masterfrom
Closed
[SPARK-56018][PYTHON] Use ruff as formatter#54840gaogaotiantian wants to merge 6 commits intoapache:masterfrom
gaogaotiantian wants to merge 6 commits intoapache:masterfrom
Conversation
| "*python/pyspark/sql/streaming/proto/*", | ||
| "*venv*/*", | ||
| ] | ||
| line-length = 100 |
Contributor
There was a problem hiding this comment.
was this changed from 88?
Member
There was a problem hiding this comment.
Yeah we use 100 length line "Code style guide" at https://spark.apache.org/contributing.html
HyukjinKwon
approved these changes
Mar 17, 2026
dongjoon-hyun
approved these changes
Mar 17, 2026
Member
There was a problem hiding this comment.
+1, LGTM (Pending CIs). Thank you for head-ups in the dev@spark mailing list, @gaogaotiantian .
BTW, this should be enforced only for Apache Spark 4.2+.
Yicong-Huang
approved these changes
Mar 17, 2026
holdenk
approved these changes
Mar 18, 2026
LuciferYang
approved these changes
Mar 19, 2026
Member
|
Merged to master. |
dongjoon-hyun
pushed a commit
that referenced
this pull request
Mar 21, 2026
### What changes were proposed in this pull request? This is a follow-up of #54840. Disables black check by default. ### Why are the changes needed? The python formatter moved from `black` to `ruff` at #54840, but `lint-python` still runs the black check if no arguments are provided and there is `black` installed, causing many failures. ```sh % ./dev/lint-python starting python compilation test... python compilation succeeded. starting black test... black checks failed: ... ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A ### Was this patch authored or co-authored using generative AI tooling? No. Closes #54928 from ueshin/issues/SPARK-56018/disable_black. Authored-by: Takuya Ueshin <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
terana
pushed a commit
to terana/spark
that referenced
this pull request
Mar 23, 2026
### What changes were proposed in this pull request?
Replace `black` with `ruff format`.
### Why are the changes needed?
There are few reasons we should use `ruff`
1. We already use `ruff` for linter, using it for `format` will reduce a dependency, which makes upgrade easier
2. `ruff` is significantly faster than `black` which is helpful for our pre-commit hooks
3. `ruff` is more customizable if we need
4. Personally I think the taste of `ruff` is slightly better than `black`. For example:
* `ruff` enforces blank spaces for `import`, `class` and `function` better
* `ruff` will put the code back in a single line if it fits
* `ruff` always uses double quote when it can
There are some other details that you'll realize if you take a look at the diff. I think overall `ruff` generates slightly better code than `black` (and `ruff` is probably a bit more strict than `black`).
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
CI needs to pass because we removed the black dependency.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes apache#54840 from gaogaotiantian/use-ruff-as-formatter.
Authored-by: Tian Gao <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
terana
pushed a commit
to terana/spark
that referenced
this pull request
Mar 23, 2026
### What changes were proposed in this pull request? This is a follow-up of apache#54840. Disables black check by default. ### Why are the changes needed? The python formatter moved from `black` to `ruff` at apache#54840, but `lint-python` still runs the black check if no arguments are provided and there is `black` installed, causing many failures. ```sh % ./dev/lint-python starting python compilation test... python compilation succeeded. starting black test... black checks failed: ... ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#54928 from ueshin/issues/SPARK-56018/disable_black. Authored-by: Takuya Ueshin <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
Replace
blackwithruff format.Why are the changes needed?
There are few reasons we should use
ruffrufffor linter, using it forformatwill reduce a dependency, which makes upgrade easierruffis significantly faster thanblackwhich is helpful for our pre-commit hooksruffis more customizable if we needruffis slightly better thanblack. For example:ruffenforces blank spaces forimport,classandfunctionbetterruffwill put the code back in a single line if it fitsruffalways uses double quote when it canThere are some other details that you'll realize if you take a look at the diff. I think overall
ruffgenerates slightly better code thanblack(andruffis probably a bit more strict thanblack).Does this PR introduce any user-facing change?
No.
How was this patch tested?
CI needs to pass because we removed the black dependency.
Was this patch authored or co-authored using generative AI tooling?
No.