Skip to content

Commit 19ec991

Browse files
gaogaotiantianHyukjinKwon
authored andcommitted
[SPARK-54632][INFRA][FOLLOW-UP] Enable ruff on our CI and lint-python
### What changes were proposed in this pull request? This add `ruff` to our docker image and enables ruff check in our CI. Also this adds ruff check in `dev/lint-python`. We want to have both `ruff` and `flake8` run in CI for a while to confirm the compatibility then we will deprecate `flake8`. ~~It is intentional to leave ruff version blank - so it uses the latest version. I think the linter rule is pretty stable and the version upgrade should not affect our workflow too much. This is an experiment about using the latest version of devtool. Pinning the version has its advantage but upgrading the version is painful. If we can occasionally (per month?) fix a small amount of code for linter, I think that's acceptable.~~ After discussion with Yicong-Huang I think it's a good idea to pin the version - so we can do all the code fix with devtool change in a single PR. We should avoid having multiple people trying to fix the code when there is a new rule. ### Why are the changes needed? `flake8` is too slow and our pinned version is just too old. We should replace it. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Local ruff test passes. ### Was this patch authored or co-authored using generative AI tooling? No Closes #53412 from gaogaotiantian/add-ruff-to-ci. Authored-by: Tian Gao <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent 7e684b3 commit 19ec991

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

dev/lint-python

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ if [[ -z "$COMPILE_TEST$BLACK_TEST$PYSPARK_CUSTOM_ERRORS_CHECK_TEST$FLAKE8_TEST$
7979
BLACK_TEST=true
8080
PYSPARK_CUSTOM_ERRORS_CHECK_TEST=true
8181
FLAKE8_TEST=true
82+
RUFF_TEST=true
8283
MYPY_TEST=true
8384
MYPY_EXAMPLES_TEST=true
8485
MYPY_DATA_TEST=true

dev/spark-test-image/lint/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
8080
RUN python3.11 -m pip install \
8181
'black==23.12.1' \
8282
'flake8==3.9.0' \
83+
'ruff==0.14.8' \
8384
'googleapis-common-protos-stubs==2.2.0' \
8485
'grpc-stubs==1.24.11' \
8586
'grpcio-status==1.76.0' \

python/pyspark/sql/tests/arrow/test_arrow_udf_typehints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def multiply_pandas(a: pd.Series, b: pd.Series) -> pd.Series:
461461

462462

463463
if __name__ == "__main__":
464-
from pyspark.sql.tests.arrow.test_arrow_udf_typehints import * # noqa: #F401
464+
from pyspark.sql.tests.arrow.test_arrow_udf_typehints import * # noqa: F401
465465

466466
try:
467467
import xmlrunner

python/pyspark/sql/tests/pandas/test_pandas_udf_typehints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def multiply_arrow(a: pa.Array, b: pa.Array) -> pa.Array:
444444

445445

446446
if __name__ == "__main__":
447-
from pyspark.sql.tests.pandas.test_pandas_udf_typehints import * # noqa: #F401
447+
from pyspark.sql.tests.pandas.test_pandas_udf_typehints import * # noqa: F401
448448

449449
try:
450450
import xmlrunner

python/pyspark/sql/tests/pandas/test_pandas_udf_typehints_with_future_annotations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ def func(col: "Union[pd.Series, pd.DataFrame]", *, col2: "pd.DataFrame") -> "pd.
367367

368368

369369
if __name__ == "__main__":
370-
from pyspark.sql.tests.pandas.test_pandas_udf_typehints_with_future_annotations import * # noqa: #F401
370+
# E501: line too long
371+
from pyspark.sql.tests.pandas.test_pandas_udf_typehints_with_future_annotations import * # noqa: F401, E501
371372

372373
try:
373374
import xmlrunner

0 commit comments

Comments
 (0)