Skip to content

Commit 3dfc5e7

Browse files
authored
chore: update librarian container to use ruff (#15536)
Update the container cli tool to use ruff instead of black and isort.
1 parent b483e92 commit 3dfc5e7

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

.generator/cli.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,22 @@ def _run_post_processor(output: str, library_id: str, is_mono_repo: bool):
348348
else:
349349
raise SYNTHTOOL_IMPORT_ERROR # pragma: NO COVER
350350

351-
# If there is no noxfile, run `isort`` and `black` on the output.
351+
# If there is no noxfile, run `ruff` on the output.
352352
# This is required for proto-only libraries which are not GAPIC.
353353
if not Path(f"{output}/{path_to_library}/noxfile.py").exists():
354-
subprocess.run(["isort", output])
355-
subprocess.run(["black", output])
354+
# TODO(https://github.com/googleapis/google-cloud-python/issues/15538):
355+
# Investigate if a `target_version needs to be maintained
356+
# or can be eliminated.
357+
target_version = "py37"
358+
common_args = [
359+
f"--target-version={target_version}",
360+
"--line-length=88",
361+
]
362+
# 1. Run Ruff to fix imports (replaces isort)
363+
subprocess.run(["ruff", "check", "--select", "I", "--fix", *common_args], check=True)
364+
365+
# 2. Run Ruff to format code (replaces black)
366+
subprocess.run(["ruff", "format", *common_args], check=True)
356367

357368
logger.info("Python post-processor ran successfully.")
358369

.generator/requirements-test.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ pytest-mock
1818
gcp-synthtool @ git+https://github.com/googleapis/synthtool@5aa438a342707842d11fbbb302c6277fbf9e4655
1919
starlark-pyo3>=2025.1
2020
build
21-
black==23.7.0
22-
isort==5.11.0
21+
ruff==0.14.14

.generator/requirements.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ gapic-generator==1.30.8 # fix mypy issue for __func__ type https://github.com/go
33
nox
44
starlark-pyo3>=2025.1
55
build
6-
black==23.7.0
7-
isort==5.11.0
6+
ruff==0.14.14

0 commit comments

Comments
 (0)