diff --git a/.generator/cli.py b/.generator/cli.py index 3e6075901fb8..4dc20c6b53cb 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -348,11 +348,22 @@ def _run_post_processor(output: str, library_id: str, is_mono_repo: bool): else: raise SYNTHTOOL_IMPORT_ERROR # pragma: NO COVER - # If there is no noxfile, run `isort`` and `black` on the output. + # If there is no noxfile, run `ruff` on the output. # This is required for proto-only libraries which are not GAPIC. if not Path(f"{output}/{path_to_library}/noxfile.py").exists(): - subprocess.run(["isort", output]) - subprocess.run(["black", output]) + # TODO(https://github.com/googleapis/google-cloud-python/issues/15538): + # Investigate if a `target_version needs to be maintained + # or can be eliminated. + target_version = "py37" + common_args = [ + f"--target-version={target_version}", + "--line-length=88", + ] + # 1. Run Ruff to fix imports (replaces isort) + subprocess.run(["ruff", "check", "--select", "I", "--fix", *common_args], check=True) + + # 2. Run Ruff to format code (replaces black) + subprocess.run(["ruff", "format", *common_args], check=True) logger.info("Python post-processor ran successfully.") diff --git a/.generator/requirements-test.in b/.generator/requirements-test.in index 59ae478b8438..c72643d50d01 100644 --- a/.generator/requirements-test.in +++ b/.generator/requirements-test.in @@ -18,5 +18,4 @@ pytest-mock gcp-synthtool @ git+https://github.com/googleapis/synthtool@5aa438a342707842d11fbbb302c6277fbf9e4655 starlark-pyo3>=2025.1 build -black==23.7.0 -isort==5.11.0 +ruff==0.14.14 diff --git a/.generator/requirements.in b/.generator/requirements.in index b8811a286483..3f72f825ed5a 100644 --- a/.generator/requirements.in +++ b/.generator/requirements.in @@ -3,5 +3,4 @@ gapic-generator==1.30.7 # replace isort and black with ruff https://github.com/g nox starlark-pyo3>=2025.1 build -black==23.7.0 -isort==5.11.0 +ruff==0.14.14