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
@@ -190,18 +190,16 @@ def test_root_format_driver_covers_all_formatter_groups(
len(group.commands) for group in formatters
]
sdk_uv_run_args = (
"uv",
"run",
"--frozen",
sys.executable,
"codex-rs/scripts/run_locked_python_tool.py",
"--project",
"sdk/python",
"--only-group",
"format",
)
scripts_uv_run_args = (
"uv",
"run",
"--frozen",
sys.executable,
"codex-rs/scripts/run_locked_python_tool.py",
"--project",
"scripts",
)
+3 -1
View File
@@ -95,10 +95,12 @@ def test_schema_refresh_only_updates_python_for_repository_schemas(monkeypatch,
runpy.run_path(str(script), run_name="__main__")
assert [args[0] for args, _kwargs in calls] == (
["cargo", "uv"] if mode == "repository" else ["cargo"]
["cargo", sys.executable] if mode == "repository" else ["cargo"]
)
assert all(kwargs["check"] for _args, kwargs in calls)
if mode == "repository":
runner = ROOT.parents[1] / "codex-rs/scripts/run_locked_python_tool.py"
assert calls[1][0][1] == str(runner)
assert calls[1][0][-3:] == [
"generate-types",
"--schema-dir",