Verify dependency hashes when running Python repository tools (#62346)

## Why

Using `uv run --frozen` keeps dependency resolution fixed but does not require
installed packages to match the hashes in `uv.lock`.

## What changed

Run Ruff for the Python SDK and repository scripts, and regenerate Python SDK
types during repository schema refreshes, through a shared runner. It exports
the selected locked dependencies, installs them into a temporary virtual
environment with `uv pip sync --require-hashes`, and runs the tool without
resyncing the environment.

## Testing

Update tests to check the formatter invocations and verify that only repository
schema refreshes invoke Python type generation through the runner.

GitOrigin-RevId: 4e84da5d227eb99c24efb9a1cc7647af82105536
This commit is contained in:
colby-oai
2026-11-18 19:21:39 +00:00
committed by copyberry
parent 42cf4edfcd
commit 0e011c0092
5 changed files with 69 additions and 15 deletions
+11 -4
View File
@@ -12,6 +12,7 @@ from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
LOCKED_PYTHON_RUNNER = "codex-rs/scripts/run_locked_python_tool.py"
@dataclass(frozen=True)
@@ -116,9 +117,8 @@ def buildifier_formatter_group(*, check: bool) -> FormatterGroup:
def python_sdk_formatter_group(*, check: bool) -> FormatterGroup:
# Each `--project` retains its local dependency and Ruff configuration context.
uv_run_args = [
"uv",
"run",
"--frozen",
sys.executable,
LOCKED_PYTHON_RUNNER,
"--project",
"sdk/python",
"--only-group",
@@ -149,7 +149,14 @@ def python_sdk_formatter_group(*, check: bool) -> FormatterGroup:
def python_scripts_formatter_group(*, check: bool) -> FormatterGroup:
args = ["uv", "run", "--frozen", "--project", "scripts", "ruff", "format"]
args = [
sys.executable,
LOCKED_PYTHON_RUNNER,
"--project",
"scripts",
"ruff",
"format",
]
if check:
args.append("--check")
args.append(".")