Skip to content

Commit 3858e54

Browse files
committed
fix ruff settings
1 parent a68d207 commit 3858e54

File tree

242 files changed

+42915
-26105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+42915
-26105
lines changed

.generator/cli.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -392,36 +392,35 @@ def _run_post_processor(output: str, library_id: str, is_mono_repo: bool):
392392
# This replaces both 'isort' and 'black' and runs in < 1 second.
393393
# We hardcode flags here to match Black defaults so you don't need config files.
394394
# logger.info("🚀 Running Ruff (Fast Formatter)...")
395+
ruff_config_path = Path("/usr/local/google/home/omairn/git/googleapis/google-cloud-python/.generator/ruff.toml").resolve()
396+
397+
if not ruff_config_path.exists():
398+
logger.warning(f"⚠️ Could not find Ruff config at {ruff_config_path}. Using defaults.")
399+
395400
try:
401+
402+
subprocess.run(["ruff", "--version"], check=False)
403+
logger.info("Running Ruff Check (Imports)...")
404+
base_args = ["ruff", "--config", str(ruff_config_path)]
405+
396406
# STEP A: Fix Imports (like isort)
397407
subprocess.run(
398-
[
399-
"ruff", "check",
400-
"--select", "I", # Only run Import sorting rules
401-
"--fix", # Auto-fix them
402-
"--line-length=88", # Match Black default
403-
"--known-first-party=google", # Prevent 'google' moving to 3rd party block
404-
output
405-
],
406-
check=False,
407-
stdout=subprocess.DEVNULL,
408-
stderr=subprocess.DEVNULL
408+
base_args + ["check", "--fix", "."],
409+
check=True,
409410
)
410411

411412
# STEP B: Format Code (like black)
412413
subprocess.run(
413-
[
414-
"ruff", "format",
415-
"--line-length=88", # Match Black default
416-
output
417-
],
418-
check=False,
419-
stdout=subprocess.DEVNULL,
420-
stderr=subprocess.DEVNULL
414+
base_args + ["format", "."],
415+
check=True,
421416
)
417+
logger.info("Ruff formatting completed successfully.")
418+
422419
except FileNotFoundError:
423420
logger.warning("⚠️ Ruff binary not found. Code will be unformatted.")
424421
logger.warning(" Please run: pip install ruff")
422+
except subprocess.CalledProcessError as e:
423+
logger.error(f"❌ Ruff failed with exit code {e.returncode}.")
425424

426425
logger.info("Python post-processor ran successfully.")
427426

.generator/ruff.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# .generator/ruff.toml
2+
3+
# Match Black's line length
4+
line-length = 88
5+
6+
[lint]
7+
# Enable Import sorting (isort)
8+
select = ["I"]
9+
10+
[lint.isort]
11+
# Force 'google' to be recognized as a first-party import
12+
known-first-party = ["google"]
13+
14+
[format]
15+
# Strictly enforce double quotes (Black style)
16+
quote-style = "double"

packages/google-cloud-vision/docs/conf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
# All configuration values have a default; values that are commented out
2626
# serve to show the default.
2727

28-
import sys
2928
import os
3029
import shlex
30+
import sys
3131

3232
# If extensions (or modules to document with autodoc) are in another directory,
3333
# add these directories to sys.path here. If the directory is relative to the
@@ -81,9 +81,9 @@
8181
root_doc = "index"
8282

8383
# General information about the project.
84-
project = u"google-cloud-vision"
85-
copyright = u"2025, Google, LLC"
86-
author = u"Google APIs"
84+
project = "google-cloud-vision"
85+
copyright = "2025, Google, LLC"
86+
author = "Google APIs"
8787

8888
# The version info for the project you're documenting, acts as replacement for
8989
# |version| and |release|, also used in various other places throughout the
@@ -283,7 +283,7 @@
283283
(
284284
root_doc,
285285
"google-cloud-vision.tex",
286-
u"google-cloud-vision Documentation",
286+
"google-cloud-vision Documentation",
287287
author,
288288
"manual",
289289
)

0 commit comments

Comments
 (0)