Skip to content

Commit 1c9fd1b

Browse files
authored
Remove isort dependency, migrate to ruff equivalent (#39411)
* Remove isort dependency, migrate to ruff equivalent * Clean up old gen clients from the ignore list
1 parent b0a7099 commit 1c9fd1b

3 files changed

Lines changed: 54 additions & 89 deletions

File tree

sdks/python/pyproject.toml

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,57 +45,6 @@ requires = [
4545
# legacy installation is needed to generate `apache_beam.portability.api` package.
4646
build-backend = "setuptools.build_meta"
4747

48-
[tool.isort]
49-
py_version = 310
50-
line_length = 120
51-
old_finders = true
52-
order_by_type = true
53-
force_single_line = true
54-
combine_star = true
55-
src_paths = ["apache_beam"]
56-
extra_standard_library = ["dataclasses"]
57-
known_third_party = ["yaml"]
58-
skip = [
59-
"apiclient.py",
60-
"avroio_test.py",
61-
"cloudpickle.py",
62-
"datastore_wordcount.py",
63-
"datastoreio_test.py",
64-
"doctests_test.py",
65-
"fast_coders_test.py",
66-
"hadoopfilesystem.py",
67-
"iobase_test.py",
68-
"main_test.py",
69-
"model.py",
70-
"preprocess.py",
71-
"process_tfma.py",
72-
"render_test.py",
73-
"slow_coders_test.py",
74-
"taxi.py",
75-
"tfdv_analyze_and_validate.py",
76-
"yaml/main.py",
77-
"yaml_testing_test.py",
78-
"bigquery_v2_client.py",
79-
"bigquery_v2_messages.py",
80-
"dataflow_v1b3_client.py",
81-
"dataflow_v1b3_messages.py",
82-
"storage_v1_client.py",
83-
"storage_v1_messages.py",
84-
"proto2_coder_test_messages_pb2.py",
85-
"rate_limit_pb2.py",
86-
"cloudbuild_v1_client.py",
87-
"cloudbuild_v1_messages.py",
88-
"boto3_client.py",
89-
]
90-
skip_glob = [
91-
"*.pxd",
92-
"*.pyx",
93-
"*pb2*.py",
94-
"**/examples/**/*.py",
95-
"**/portability/api/**/*.py",
96-
"**/portability/api/__init__.py",
97-
]
98-
9948
[tool.ruff]
10049
exclude = [
10150
".bzr",
@@ -127,16 +76,19 @@ exclude = [
12776
"*.pxd",
12877
"*.pyx",
12978
"*pb2*.py",
79+
"*.ipynb",
80+
"**/*.ipynb",
13081
"**/examples/**/*.py",
13182
"**/examples/**/*.ipynb",
13283
"**/portability/api/**/*.py",
13384
"**/portability/api/__init__.py",
13485
]
13586
target-version = "py310"
13687
src = ["apache_beam"]
88+
line-length = 120
13789

13890
[tool.ruff.lint]
139-
select = ["E9", "PL", "F821", "F822", "F823", "UP006"]
91+
select = ["E9", "PL", "F821", "F822", "F823", "UP006", "I"]
14092
ignore = [
14193
# Ignored Pylint Checks
14294
"PLC0415", # import-outside-toplevel
@@ -175,6 +127,55 @@ unfixable = []
175127
# Allow unused variables when underscore-prefixed.
176128
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
177129

130+
[tool.ruff.lint.isort]
131+
force-single-line = true
132+
order-by-type = true
133+
extra-standard-library = ["dataclasses"]
134+
known-third-party = ["yaml"]
135+
known-first-party = ["apache_beam"]
136+
137+
[tool.ruff.lint.per-file-ignores]
138+
"**/apiclient.py" = ["I"]
139+
"**/avroio_test.py" = ["I"]
140+
"**/cloudpickle.py" = ["I"]
141+
"**/datastore_wordcount.py" = ["I"]
142+
"**/datastoreio_test.py" = ["I"]
143+
"**/doctests_test.py" = ["I"]
144+
"**/fast_coders_test.py" = ["I"]
145+
"**/hadoopfilesystem.py" = ["I"]
146+
"**/iobase_test.py" = ["I"]
147+
"**/main_test.py" = ["I"]
148+
"**/model.py" = ["I"]
149+
"**/preprocess.py" = ["I"]
150+
"**/process_tfma.py" = ["I"]
151+
"**/render_test.py" = ["I"]
152+
"**/slow_coders_test.py" = ["I"]
153+
"**/taxi.py" = ["I"]
154+
"**/tfdv_analyze_and_validate.py" = ["I"]
155+
"**/yaml/main.py" = ["I"]
156+
"**/yaml_testing_test.py" = ["I"]
157+
"**/bigquery_v2_client.py" = ["I"]
158+
"**/bigquery_v2_messages.py" = ["I"]
159+
"**/proto2_coder_test_messages_pb2.py" = ["I"]
160+
"**/rate_limit_pb2.py" = ["I"]
161+
"**/boto3_client.py" = ["I"]
162+
"**/coders_property_based_test.py" = ["I"]
163+
"**/filebasedsource_test.py" = ["I"]
164+
"**/bigtableio_it_test.py" = ["I"]
165+
"**/bigtableio_test.py" = ["I"]
166+
"**/mongodbio.py" = ["I"]
167+
"**/textio_test.py" = ["I"]
168+
"**/streaming_cache.py" = ["I"]
169+
"**/pcoll_visualization.py" = ["I"]
170+
"**/interactive_environment.py" = ["I"]
171+
"**/pipeline_instrument_test.py" = ["I"]
172+
"**/worker_handlers.py" = ["I"]
173+
"**/feast_feature_store_it_test.py" = ["I"]
174+
"**/vertex_ai_feature_store_it_test.py" = ["I"]
175+
"**/vertex_ai_feature_store_test.py" = ["I"]
176+
"setup.py" = ["I"]
177+
"container/**" = ["I"]
178+
178179
[tool.pyrefly]
179180
project-includes = ["apache_beam"]
180181
python-version = "3.10.0"

sdks/python/scripts/run_lint.sh

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
# limitations under the License.
1717
#
1818

19-
# This script will run ruff and isort on all module files.
19+
# This script will run ruff on all module files.
2020
#
2121
# Use "ruff check apache_beam" to run ruff all files.
22-
# Use "isort apache_beam" to run isort all files.
2322
#
2423
# The exit-code of the script indicates success or a failure.
2524

@@ -82,40 +81,6 @@ echo -e "Linting modules:\n${MODULE}"
8281
echo "Running ruff..."
8382
ruff check ${MODULE} --extend-exclude="$FILES_TO_IGNORE"
8483

85-
echo "Running isort..."
86-
# Skip files where isort is behaving weirdly
87-
ISORT_EXCLUDED=(
88-
"apiclient.py"
89-
"avroio_test.py"
90-
"cloudpickle.py"
91-
"datastore_wordcount.py"
92-
"datastoreio_test.py"
93-
"doctests_test.py"
94-
"fast_coders_test.py"
95-
"hadoopfilesystem.py"
96-
"iobase_test.py"
97-
"main_test.py"
98-
"model.py"
99-
"preprocess.py"
100-
"process_tfma.py"
101-
"render_test.py"
102-
"slow_coders_test.py"
103-
"taxi.py"
104-
"tfdv_analyze_and_validate.py"
105-
"yaml/main.py"
106-
"main_test.py"
107-
"yaml_testing_test.py"
108-
)
109-
SKIP_PARAM=""
110-
for file in "${ISORT_EXCLUDED[@]}"; do
111-
SKIP_PARAM="$SKIP_PARAM --skip $file"
112-
done
113-
for file in "${EXCLUDED_GENERATED_FILES[@]}"; do
114-
SKIP_PARAM="$SKIP_PARAM --skip $(basename $file)"
115-
done
116-
isort ${MODULE} -p apache_beam --line-width 120 --check-only --order-by-type \
117-
--combine-star --force-single-line-imports --diff --magic-placement ${SKIP_PARAM}
118-
11984
echo "Checking unittest.main..."
12085
TESTS_MISSING_MAIN=$(
12186
find ${MODULE} \

sdks/python/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ def get_portability_package_data():
461461
# BEAM-8840: Do NOT use tests_require or setup_requires.
462462
extras_require={
463463
'dev': [
464-
'isort==7.0.0',
465464
'pyrefly==0.54.0',
466465
'ruff==0.15.7',
467466
'yapf==0.43.0',

0 commit comments

Comments
 (0)